-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support new spawn #13
Conversation
src/process_info.rs
Outdated
PROCESS_CONTEXT_ID.with(|f| f.borrow().clone()) | ||
} | ||
|
||
pub fn inherited_fds(&self) -> Vec<Fd> { |
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.
return by reference.
src/process_info.rs
Outdated
|
||
pub fn wait(&self) { | ||
let (lock, cvar) = &*self.data; | ||
let mut event = lock.lock().unwrap(); |
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.
This name "event" is inconsistent: see notify
.
src/spawn.rs
Outdated
0 | ||
} | ||
|
||
fn read(&self, fd: Fd, buf: *mut c_void, length: *mut usize) -> c_int { |
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 100 bytes of data are written from one end of the pipe and the other end performs the following actions:
- Reads 30 bytes
- Reads 40 bytes
- Reads 30 bytes
The simulator is unable to handle this correctly.
src/global_data.rs
Outdated
} | ||
} | ||
impl TxID { | ||
fn next(&mut self) -> Self { |
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 do you modify the original data here, but clone a copy of the data as the return value at the same time?
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.
In many places, the next
step is HashMap::insert
. This way, the return is more convenient to use.
To facilitate version switching of ckb-std during debugging, ckb-std-wrapper has been added in the tests as a dependency for ckb-std
* Dealing with read/write synchronization issues
.github/workflows/rust.yaml
Outdated
@@ -14,5 +14,13 @@ jobs: | |||
|
|||
steps: | |||
- uses: actions/checkout@v3 | |||
- name: Install llvm 16 | |||
run: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 16 && rm llvm.sh |
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.
use llvm-18
src/spawn.rs
Outdated
pub extern "C" fn ckb_wait(pid: u64, code: *mut i8) -> c_int { | ||
let pid: ProcID = pid.into(); | ||
if !get_cur_tx!().has_proc(&pid) { | ||
return 5; // WaitFailure |
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.
define the errors first, no magic numbers.
src/lib.rs
Outdated
@@ -56,7 +66,7 @@ lazy_static! { | |||
} | |||
|
|||
fn assert_vm_version() { | |||
if SETUP.vm_version != 1 { | |||
if SETUP.vm_version != 1 && SETUP.vm_version != 2 { |
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 may be version 3 in the future, use if SETUP.vm_version == 0
instead
The simulator uses multithreading to simulate spawn, and each spawn will create a new thread.
After this change, need to use the matching ckb-std to use it in the CKB contract.
Modify