Skip to content
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

Add BPF support & C-based BPF tic-tac-toe #1422

Merged
merged 7 commits into from
Oct 4, 2018

Conversation

jackcmay
Copy link
Contributor

@jackcmay jackcmay commented Oct 4, 2018

This PR addresses the next two boxes of #1255

Making this a PR because it makes changes to the build system, otherwise, most of the changes are featurized with bpf_c

What this PR does include:

  • Integration of the programs into the build system
  • Featurized BPF (use --features="bpf_c")
  • C-based move_funds BPF program
  • C-based tic-tac-toe BPF program
  • Skeleton Rust-based BPF program to play around with
    • Not built as part of the Solana workspace, must be built via shell script independently

What it does not include and next steps:

  • Integration into the bank
  • Programs loaded into Account.Userdata
  • Frontend changes to support loading and calling programs

@jackcmay jackcmay added this to the v0.10 Pillbox milestone Oct 4, 2018
@jackcmay jackcmay self-assigned this Oct 4, 2018
@jackcmay jackcmay changed the title Add bpf support & C-based tic-tac-toe Add BPF support & C-based tic-tac-toe Oct 4, 2018
@jackcmay jackcmay changed the title Add BPF support & C-based tic-tac-toe Add BPF support & C-based BPF tic-tac-toe Oct 4, 2018
Copy link
Member

@mvines mvines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like shellcheck is a little angry still.

The duplication in the various build.sh and the common C runtime prelude that’s included in the various C examples (like magic number 6) feels like a WIP. I guess all that is going to get ripped out as we continue to iterate on this, so I’m ok with it as is for now.

Cargo.toml Show resolved Hide resolved
@@ -0,0 +1,12 @@
#!/bin/bash

set -e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: add -ex to the shebang instead: #!/bin/bash -ex

@@ -0,0 +1,13 @@
#!/bin/sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be /bin/bash as there are bash-specific features in here

//#include <stddef.h>

#if 1
// one way to define a helper function is with idex as a fixed value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“idex” => “index”?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the 6 come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux kernel definition. This is another possible modification I'd like to make to rbpf to make it more general

src/dynamic_program.rs Show resolved Hide resolved

fn verify_prog_len(prog: &[u8]) {
if prog.len() % ebpf::INSN_SIZE != 0 {
panic!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a Result<> be returned instead of panicking?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This verifier was pretty much pulled directly from rbpf and contrary to it returning a bool rpbf ignores the return value and relies on panic. This is another thing that's on my list of things to change about rbpf, fail gracefully

@jackcmay
Copy link
Contributor Author

jackcmay commented Oct 4, 2018

Yeah, the boilerplate code in the programs will be consolidated to a common library. Magic number 6 is defined by rbps currently, I'll create a definition for it.

@jackcmay jackcmay merged commit 13d4443 into solana-labs:master Oct 4, 2018
@jackcmay jackcmay deleted the add_bpf_support branch October 4, 2018 17:18
vkomenda pushed a commit to vkomenda/solana that referenced this pull request Aug 29, 2021
…na-labs#1422)

* stake-pool-cli: Fix withdraw calc for CLI / program consistency

* Run cargo fmt

* Integrate review feedback
yihau pushed a commit that referenced this pull request May 18, 2024
* Add detailed metrics reporting for packet filtering

* fix conflicts
lijunwangs pushed a commit to lijunwangs/solana that referenced this pull request May 28, 2024
…abs#1422)

* Add detailed metrics reporting for packet filtering

* fix conflicts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants