-
Notifications
You must be signed in to change notification settings - Fork 764
Implement and integrate Rust block store #1885
Implement and integrate Rust block store #1885
Conversation
83d20c7
to
51c0225
Compare
This is required to debug certain FFI and threading issues and should be one by default to save time. Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
Move this code to the Python FFI module and make it more general purpose. Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
Rewrite the Python blockstore in Rust. Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
Replace the Python blockstore with the Rust blockstoer. Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
These are not used. Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
The FFI layer was no longer required and the ChainController can access the CommiStore directly now. Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
The Rust blockstore only exposes those FFI methods required by client handlers, and these methods are already covered by the client request handlers. Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
51c0225
to
677f17b
Compare
677f17b
to
4ade52d
Compare
DictDatabase no long works with BlockStore, so we need to replace its usage. Signed-off-by: Adam Ludvik <ludvik@bitwise.io>
4ade52d
to
aa4e3ea
Compare
let gil = Python::acquire_gil(); | ||
let py = gil.python(); | ||
let py_block_store = PyBlockStore::new(PyObject::from_borrowed_ptr(py, block_store)); | ||
let commit_store = Box::from_raw(commit_store as *mut CommitStore); |
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 use from_raw
/into_raw
here? Why don't you just use the pointer?
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 don’t have a good reason for not just using the pointer. I thought I needed to do from_raw/into_raw to get the clone to work right, but I was confused.
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 are lot's of examples of this in chain_ffi.rs
, including a call to clone
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.
The thing that threw me off is the type expected by add_store()
is Box<BlockStore>
, not CommitStore
, so you can't do (*(commit_store as *mut CommitStore))
.
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 am changing my mind again. Trying to do (*(commit_store as *mut Box<CommitStore>))
is bad, causes a seg fault, so I think I do need the from_raw/into_raw.
Replaces the Python implementation of the blockstore with a pure Rust implementation, dubbed the CommitStore to be consistent with the naming scheme used by the BlockManager API.