Rename programs to instruction_processors (#3789)
* Rename programs to instruction_processors * Updates around the code base to support instruction_processors rename * Kabab instruction_processors * Update Cargo.toml files and scripts to use instruction-processors * Update Cargo.toml to use instruction-processors * Update CI scripts to use instruction-processors
This commit is contained in:
1
programs/bpf/c/.gitignore
vendored
1
programs/bpf/c/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/out/
|
@ -1,2 +0,0 @@
|
||||
BPF_SDK := ../../../sdk/bpf
|
||||
include $(BPF_SDK)/bpf.mk
|
@ -1,30 +0,0 @@
|
||||
/**
|
||||
* @brief Benchmark program that does work
|
||||
*
|
||||
* Counts Armstrong Numbers between 1 and x
|
||||
*/
|
||||
|
||||
#include <solana_sdk.h>
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
uint64_t x = *(uint64_t *) input;
|
||||
uint64_t *result = (uint64_t *) input + 1;
|
||||
uint64_t count = 0;
|
||||
|
||||
for (int i = 1; i <= x; i++) {
|
||||
uint64_t temp = i;
|
||||
uint64_t num = 0;
|
||||
while (temp != 0) {
|
||||
uint64_t rem = (temp % 10);
|
||||
num += rem * rem * rem;
|
||||
temp /= 10;
|
||||
}
|
||||
if (i == num) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
sol_log_64(x, count, 0, 0, 0);
|
||||
*result = count;
|
||||
return true;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#include <criterion/criterion.h>
|
||||
#include "bench_alu.c"
|
||||
|
||||
Test(bench_alu, sanity) {
|
||||
uint64_t input[] = {500, 0};
|
||||
|
||||
cr_assert(entrypoint((uint8_t *) input));
|
||||
|
||||
cr_assert_eq(input[0], 500);
|
||||
cr_assert_eq(input[1], 5);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* @brief Example C-based BPF program that prints out the parameters
|
||||
* passed to it
|
||||
*/
|
||||
#include <solana_sdk.h>
|
||||
|
||||
#include "helper.h"
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
sol_log(__FILE__);
|
||||
helper_function();
|
||||
sol_log(__FILE__);
|
||||
return true;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* @brief Example C-based BPF program that prints out the parameters
|
||||
* passed to it
|
||||
*/
|
||||
#include <solana_sdk.h>
|
||||
|
||||
#include "helper.h"
|
||||
|
||||
void helper_function(void) {
|
||||
sol_log(__FILE__);
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
/**
|
||||
* @brief Example C-based BPF program that prints out the parameters
|
||||
* passed to it
|
||||
*/
|
||||
#include <solana_sdk.h>
|
||||
|
||||
void helper_function(void);
|
@ -1,36 +0,0 @@
|
||||
/**
|
||||
* @brief Example C-based BPF program that moves funds from one account to
|
||||
* another
|
||||
*/
|
||||
|
||||
#include <solana_sdk.h>
|
||||
|
||||
/**
|
||||
* Number of SolKeyedAccount expected. The program should bail if an
|
||||
* unexpected number of accounts are passed to the program's entrypoint
|
||||
*/
|
||||
#define NUM_KA 3
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
SolKeyedAccount ka[NUM_KA];
|
||||
SolParameters params = (SolParameters) { .ka = ka };
|
||||
|
||||
if (!sol_deserialize(input, ¶ms, SOL_ARRAY_SIZE(ka))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!params.ka[0].is_signer) {
|
||||
sol_log("Transaction not signed by key 0");
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t lamports = *(int64_t *)params.data;
|
||||
if (*params.ka[0].lamports >= lamports) {
|
||||
*params.ka[0].lamports -= lamports;
|
||||
*params.ka[2].lamports += lamports;
|
||||
// sol_log_64(0, 0, *ka[0].lamports, *ka[2].lamports, lamports);
|
||||
} else {
|
||||
// sol_log_64(0, 0, 0xFF, *ka[0].lamports, lamports);
|
||||
}
|
||||
return true;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
#include <solana_sdk.h>
|
||||
|
||||
static const char msg[] = "This is a message";
|
||||
static const char msg2[] = "This is a different message";
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
sol_log((char*)msg);
|
||||
sol_log((char*)msg2);
|
||||
return true;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/**
|
||||
* @brief Example C++-based BPF program that prints out the parameters
|
||||
* passed to it
|
||||
*/
|
||||
#include <solana_sdk.h>
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
SolKeyedAccount ka[1];
|
||||
SolParameters params = (SolParameters) { .ka = ka };
|
||||
|
||||
sol_log(__FILE__);
|
||||
|
||||
if (!sol_deserialize(input, ¶ms, SOL_ARRAY_SIZE(ka))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Log the provided input parameters. In the case of the no-op
|
||||
// program, no account keys or input data are expected but real
|
||||
// programs will have specific requirements so they can do their work.
|
||||
sol_log_params(¶ms);
|
||||
return true;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* @brief Example C-based BPF program that prints out the parameters
|
||||
* passed to it
|
||||
*/
|
||||
#include <solana_sdk.h>
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
SolKeyedAccount ka[1];
|
||||
SolParameters params = (SolParameters) { .ka = ka };
|
||||
|
||||
sol_log(__FILE__);
|
||||
|
||||
if (!sol_deserialize(input, ¶ms, SOL_ARRAY_SIZE(ka))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Log the provided input parameters. In the case of the no-op
|
||||
// program, no account keys or input data are expected but real
|
||||
// programs will have specific requirements so they can do their work.
|
||||
sol_log_params(¶ms);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* @brief test program that generates BPF PC relative call instructions
|
||||
*/
|
||||
|
||||
#include <solana_sdk.h>
|
||||
|
||||
void __attribute__ ((noinline)) helper() {
|
||||
sol_log(__func__);
|
||||
}
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
sol_log(__func__);
|
||||
helper();
|
||||
return true;
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
#include <solana_sdk.h>
|
||||
|
||||
struct foo {const uint8_t *input;};
|
||||
void foo(const uint8_t *input, struct foo foo) ;
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
struct foo f;
|
||||
f.input = input;
|
||||
foo(input, f);
|
||||
return true;
|
||||
}
|
||||
|
||||
void foo(const uint8_t *input, struct foo foo) {
|
||||
sol_log_64(0, 0, 0, (uint64_t)input, (uint64_t)foo.input);
|
||||
sol_assert(input == foo.input);
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
#include <solana_sdk.h>
|
||||
|
||||
struct test_struct { uint64_t x; uint64_t y; uint64_t z;};
|
||||
|
||||
static struct test_struct __attribute__ ((noinline)) test_function(void) {
|
||||
struct test_struct s;
|
||||
s.x = 3;
|
||||
s.y = 4;
|
||||
s.z = 5;
|
||||
return s;
|
||||
}
|
||||
|
||||
extern bool entrypoint(const uint8_t* input) {
|
||||
struct test_struct s = test_function();
|
||||
sol_log("foobar");
|
||||
if (s.x + s.y + s.z == 12 ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user