-
Notifications
You must be signed in to change notification settings - Fork 118
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
[x/programs] safe wrapper around C ffi interface #869
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iFrostizz
requested review from
samliok,
dboehm-avalabs and
richardpringle
as code owners
April 26, 2024 15:00
richardpringle
requested changes
Apr 26, 2024
Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com>
richardpringle
approved these changes
Apr 29, 2024
iFrostizz
added a commit
to iFrostizz/hypersdk
that referenced
this pull request
Apr 30, 2024
* macro skeleton * write macro for ffi-safe bindings * avoid panicking todo! Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * remove unused arms --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com>
richardpringle
added a commit
that referenced
this pull request
Apr 30, 2024
* support program passing in param * fix inter-program interaction * update fixture * keep using `SmartPtr` for now * remove the need of a new Param type * lint * remove param * fix nits * remove whitespace * Cached state values in the program state (#840) * add cache * implement cache reads * actually cache reads * implement cache delete and handle borsch errors * use only one cache map * remove flushed bool * root of transactions by stateless merkledb * make root generation a function * preallocate memory for merkle array and consumebytes flag * add <*.code-workspace> to .gitignore and remove it from git commit * move root generation func to merkle package, tx root by items of [txID + result] * rebase & blk marshal/unmarshal & merkleroot to ids.ID * write benches for the merkle package * use crypto/rand, fix var name, report allocs * put the 10k bench back * pass config by parameter * happy clippy * borrow V * add TODO * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "put the 10k bench back" This reverts commit 058d7e7. * Revert "use crypto/rand, fix var name, report allocs" This reverts commit 214005b. * Revert "write benches for the merkle package" This reverts commit 07993bf. * Revert "rebase & blk marshal/unmarshal & merkleroot to ids.ID" This reverts commit 7442836. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "add <*.code-workspace> to .gitignore and remove it from git commit" This reverts commit ce00289. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * merge main! * merge imports --------- Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * [x/programs] safe wrapper around C ffi interface (#869) * macro skeleton * write macro for ffi-safe bindings * avoid panicking todo! Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * remove unused arms --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org>
iFrostizz
added a commit
that referenced
this pull request
May 1, 2024
* support program passing in param * fix inter-program interaction * update fixture * keep using `SmartPtr` for now * remove the need of a new Param type * lint * remove param * fix nits * remove whitespace * Cached state values in the program state (#840) * add cache * implement cache reads * actually cache reads * implement cache delete and handle borsch errors * use only one cache map * remove flushed bool * root of transactions by stateless merkledb * make root generation a function * preallocate memory for merkle array and consumebytes flag * add <*.code-workspace> to .gitignore and remove it from git commit * move root generation func to merkle package, tx root by items of [txID + result] * rebase & blk marshal/unmarshal & merkleroot to ids.ID * write benches for the merkle package * use crypto/rand, fix var name, report allocs * put the 10k bench back * pass config by parameter * happy clippy * borrow V * add TODO * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "put the 10k bench back" This reverts commit 058d7e7. * Revert "use crypto/rand, fix var name, report allocs" This reverts commit 214005b. * Revert "write benches for the merkle package" This reverts commit 07993bf. * Revert "rebase & blk marshal/unmarshal & merkleroot to ids.ID" This reverts commit 7442836. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "add <*.code-workspace> to .gitignore and remove it from git commit" This reverts commit ce00289. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * merge main! * merge imports --------- Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * [x/programs] safe wrapper around C ffi interface (#869) * macro skeleton * write macro for ffi-safe bindings * avoid panicking todo! Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * remove unused arms --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org>
iFrostizz
added a commit
to iFrostizz/hypersdk
that referenced
this pull request
May 1, 2024
* macro skeleton * write macro for ffi-safe bindings * avoid panicking todo! Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * remove unused arms --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com>
iFrostizz
added a commit
to iFrostizz/hypersdk
that referenced
this pull request
May 1, 2024
* macro skeleton * write macro for ffi-safe bindings * avoid panicking todo! Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * remove unused arms --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com>
richardpringle
added a commit
that referenced
this pull request
May 2, 2024
* support program passing in param * fix inter-program interaction * update fixture * keep using `SmartPtr` for now * remove the need of a new Param type * lint * remove param * fix nits * remove whitespace * stop using SmartPtr * fix tests * Cached state values in the program state (#840) * add cache * implement cache reads * actually cache reads * implement cache delete and handle borsch errors * use only one cache map * remove flushed bool * root of transactions by stateless merkledb * make root generation a function * preallocate memory for merkle array and consumebytes flag * add <*.code-workspace> to .gitignore and remove it from git commit * move root generation func to merkle package, tx root by items of [txID + result] * rebase & blk marshal/unmarshal & merkleroot to ids.ID * write benches for the merkle package * use crypto/rand, fix var name, report allocs * put the 10k bench back * pass config by parameter * happy clippy * borrow V * add TODO * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "put the 10k bench back" This reverts commit 058d7e7. * Revert "use crypto/rand, fix var name, report allocs" This reverts commit 214005b. * Revert "write benches for the merkle package" This reverts commit 07993bf. * Revert "rebase & blk marshal/unmarshal & merkleroot to ids.ID" This reverts commit 7442836. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "add <*.code-workspace> to .gitignore and remove it from git commit" This reverts commit ce00289. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * merge main! * merge imports --------- Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * stop using SmartPtr * Cached state values in the program state (#840) * add cache * implement cache reads * actually cache reads * implement cache delete and handle borsch errors * use only one cache map * remove flushed bool * root of transactions by stateless merkledb * make root generation a function * preallocate memory for merkle array and consumebytes flag * add <*.code-workspace> to .gitignore and remove it from git commit * move root generation func to merkle package, tx root by items of [txID + result] * rebase & blk marshal/unmarshal & merkleroot to ids.ID * write benches for the merkle package * use crypto/rand, fix var name, report allocs * put the 10k bench back * pass config by parameter * happy clippy * borrow V * add TODO * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "put the 10k bench back" This reverts commit 058d7e7. * Revert "use crypto/rand, fix var name, report allocs" This reverts commit 214005b. * Revert "write benches for the merkle package" This reverts commit 07993bf. * Revert "rebase & blk marshal/unmarshal & merkleroot to ids.ID" This reverts commit 7442836. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "add <*.code-workspace> to .gitignore and remove it from git commit" This reverts commit ce00289. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * merge main! * merge imports --------- Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * [x/programs] safe wrapper around C ffi interface (#869) * macro skeleton * write macro for ffi-safe bindings * avoid panicking todo! Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * remove unused arms --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * support program passing in param * keep using `SmartPtr` for now * remove the need of a new Param type * lint * stop using SmartPtr * fix tests * back off file * handle put and delete return as a status and remove the `SmartPointer` * cargo fmt * fix test * pass only context ptr as i32 * fix token test * lint * remove ignored lint * update fixtures * move `CPointer` from `program` to `memory` * update fixutes to release * cargo fmt * Consolidate CI (#828) * Add rust-ci local github-action * Abstract install-go action * Centralize Go install parameters * Consolidate CI * Comment out code coverage * Finish centralizing the Go installation for CI * Handle releases * Fix passing secret to release-actions * [ci] Small Tweaks (#875) * nits * remove labels --------- Co-authored-by: Patrick O'Grady <prohb125@gmail.com> * Update vm-release.yml (#876) Signed-off-by: Richard Pringle <richard.pringle@avalabs.org> * fix inter-program interaction * keep using `SmartPtr` for now * lint * remove param * fix nits * stop using SmartPtr * fix tests * Cached state values in the program state (#840) * add cache * implement cache reads * actually cache reads * implement cache delete and handle borsch errors * use only one cache map * remove flushed bool * root of transactions by stateless merkledb * make root generation a function * preallocate memory for merkle array and consumebytes flag * add <*.code-workspace> to .gitignore and remove it from git commit * move root generation func to merkle package, tx root by items of [txID + result] * rebase & blk marshal/unmarshal & merkleroot to ids.ID * write benches for the merkle package * use crypto/rand, fix var name, report allocs * put the 10k bench back * pass config by parameter * happy clippy * borrow V * add TODO * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "put the 10k bench back" This reverts commit 058d7e7. * Revert "use crypto/rand, fix var name, report allocs" This reverts commit 214005b. * Revert "write benches for the merkle package" This reverts commit 07993bf. * Revert "rebase & blk marshal/unmarshal & merkleroot to ids.ID" This reverts commit 7442836. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "add <*.code-workspace> to .gitignore and remove it from git commit" This reverts commit ce00289. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * merge main! * merge imports --------- Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * stop using SmartPtr * Cached state values in the program state (#840) * add cache * implement cache reads * actually cache reads * implement cache delete and handle borsch errors * use only one cache map * remove flushed bool * root of transactions by stateless merkledb * make root generation a function * preallocate memory for merkle array and consumebytes flag * add <*.code-workspace> to .gitignore and remove it from git commit * move root generation func to merkle package, tx root by items of [txID + result] * rebase & blk marshal/unmarshal & merkleroot to ids.ID * write benches for the merkle package * use crypto/rand, fix var name, report allocs * put the 10k bench back * pass config by parameter * happy clippy * borrow V * add TODO * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "put the 10k bench back" This reverts commit 058d7e7. * Revert "use crypto/rand, fix var name, report allocs" This reverts commit 214005b. * Revert "write benches for the merkle package" This reverts commit 07993bf. * Revert "rebase & blk marshal/unmarshal & merkleroot to ids.ID" This reverts commit 7442836. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "add <*.code-workspace> to .gitignore and remove it from git commit" This reverts commit ce00289. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * merge main! * merge imports --------- Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * [x/programs] safe wrapper around C ffi interface (#869) * macro skeleton * write macro for ffi-safe bindings * avoid panicking todo! Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * remove unused arms --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * keep using `SmartPtr` for now * fix tests * handle put and delete return as a status and remove the `SmartPointer` * cargo fmt * move `CPointer` from `program` to `memory` * cargo fmt --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> Signed-off-by: Richard Pringle <richard.pringle@avalabs.org> Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> Co-authored-by: Patrick O'Grady <prohb125@gmail.com>
iFrostizz
added a commit
that referenced
this pull request
May 6, 2024
* support program passing in param * fix inter-program interaction * update fixture * keep using `SmartPtr` for now * remove the need of a new Param type * lint * remove param * fix nits * remove whitespace * Cached state values in the program state (#840) * add cache * implement cache reads * actually cache reads * implement cache delete and handle borsch errors * use only one cache map * remove flushed bool * root of transactions by stateless merkledb * make root generation a function * preallocate memory for merkle array and consumebytes flag * add <*.code-workspace> to .gitignore and remove it from git commit * move root generation func to merkle package, tx root by items of [txID + result] * rebase & blk marshal/unmarshal & merkleroot to ids.ID * write benches for the merkle package * use crypto/rand, fix var name, report allocs * put the 10k bench back * pass config by parameter * happy clippy * borrow V * add TODO * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "put the 10k bench back" This reverts commit 058d7e7. * Revert "use crypto/rand, fix var name, report allocs" This reverts commit 214005b. * Revert "write benches for the merkle package" This reverts commit 07993bf. * Revert "rebase & blk marshal/unmarshal & merkleroot to ids.ID" This reverts commit 7442836. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "add <*.code-workspace> to .gitignore and remove it from git commit" This reverts commit ce00289. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * merge main! * merge imports --------- Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * [x/programs] safe wrapper around C ffi interface (#869) * macro skeleton * write macro for ffi-safe bindings * avoid panicking todo! Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * remove unused arms --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org>
richardpringle
added a commit
that referenced
this pull request
May 14, 2024
…rough plan run (#884) * fix logging * fix nits * set log level to error in the simulator client & write logs to Stderr * [x/programs] Fix program calling another program on the Rust side (#866) * support program passing in param * fix inter-program interaction * update fixture * keep using `SmartPtr` for now * remove the need of a new Param type * lint * remove param * fix nits * remove whitespace * Cached state values in the program state (#840) * add cache * implement cache reads * actually cache reads * implement cache delete and handle borsch errors * use only one cache map * remove flushed bool * root of transactions by stateless merkledb * make root generation a function * preallocate memory for merkle array and consumebytes flag * add <*.code-workspace> to .gitignore and remove it from git commit * move root generation func to merkle package, tx root by items of [txID + result] * rebase & blk marshal/unmarshal & merkleroot to ids.ID * write benches for the merkle package * use crypto/rand, fix var name, report allocs * put the 10k bench back * pass config by parameter * happy clippy * borrow V * add TODO * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "put the 10k bench back" This reverts commit 058d7e7. * Revert "use crypto/rand, fix var name, report allocs" This reverts commit 214005b. * Revert "write benches for the merkle package" This reverts commit 07993bf. * Revert "rebase & blk marshal/unmarshal & merkleroot to ids.ID" This reverts commit 7442836. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "add <*.code-workspace> to .gitignore and remove it from git commit" This reverts commit ce00289. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * Revert "pass config by parameter" This reverts commit 4aec589. * Revert "move root generation func to merkle package, tx root by items of [txID + result]" This reverts commit e551960. * Revert "preallocate memory for merkle array and consumebytes flag" This reverts commit 68e49b6. * Revert "make root generation a function" This reverts commit aa44f97. * merge main! * merge imports --------- Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * [x/programs] safe wrapper around C ffi interface (#869) * macro skeleton * write macro for ffi-safe bindings * avoid panicking todo! Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> * remove unused arms --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * stdin subcommand * use argparse * iteratively parse subcommand approach * use a real shell parser * nil pointer deref * enable steps reading from stdin * run steps sequentially * sequential plan * reduce changes * read plan from file * fix hanging on stdout result * fix forgotten stdout * kill process to avoid EOF * add failing assertion test and fix unreachable in simulator * apply review suggestions * fix last nits * add license * apply commit suggestions * apply review suggestions * own the data streams instead * stop using double pointers * Make `SimulatorChild` generic * simplify stdin run command interaction * fix nits * remove useless test * address most comments * fix handle getting * pass db to `Run` * Make delete return the old data (#890) * Make delete return the old data * Add comments about enum * Make `#[public]` ffi functions private and unsafe (#893) * Make `#[public]` ffi functions private and unsafe * Fix macro warning through type swap * Encapsulate mutability in the macro * [x/programs] Debug arbitrary variable in programs (#892) * add log * reb * implement linker function * remove debug leftover * remove host file * remove unused explicit type * apply review suggestions * address review * Remove `Log` error from `state::Error` Signed-off-by: Richard Pringle <rpring9@gmail.com> --------- Signed-off-by: Richard Pringle <rpring9@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org> * Make Rust crate naming conventions consistent (#895) * Make all #[public] functions allocate the response (#896) --------- Signed-off-by: Franfran <51274081+iFrostizz@users.noreply.github.com> Signed-off-by: Richard Pringle <rpring9@gmail.com> Co-authored-by: bianyuanop <chen.me.nan@gmail.com> Co-authored-by: Richard Pringle <richard.pringle@avalabs.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mentioning #862
In an effort to avoid repetitions when defining the C interface and make it safer, create a macro that should be used when defining new hosts.
TODO in a followup PR: Use
*const u8
for the pointer offset andusize
for the pointer length instead ofi64
for everything