From 9cf5939965e42b3f18121c871f347ee686589b40 Mon Sep 17 00:00:00 2001 From: Lucas Ste <38472950+LucasSte@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:25:25 -0300 Subject: [PATCH] Remove `cargo-build-bpf` and `cargo-test-bpf` (#2040) --- Cargo.lock | 12 - Cargo.toml | 2 - cargo-build-bpf | 19 -- cargo-test-bpf | 20 -- sdk/bpf/.gitignore | 11 - sdk/bpf/c/README.md | 42 --- sdk/bpf/c/bpf.ld | 24 -- sdk/bpf/c/bpf.mk | 313 --------------------- sdk/bpf/c/inc/deserialize_deprecated.h | 1 - sdk/bpf/c/inc/sol/alt_bn128.h | 51 ---- sdk/bpf/c/inc/sol/assert.h | 56 ---- sdk/bpf/c/inc/sol/big_mod_exp.h | 32 --- sdk/bpf/c/inc/sol/blake3.h | 39 --- sdk/bpf/c/inc/sol/constants.h | 18 -- sdk/bpf/c/inc/sol/cpi.h | 138 --------- sdk/bpf/c/inc/sol/deserialize.h | 137 --------- sdk/bpf/c/inc/sol/deserialize_deprecated.h | 119 -------- sdk/bpf/c/inc/sol/entrypoint.h | 53 ---- sdk/bpf/c/inc/sol/inc/alt_bn128.inc | 67 ----- sdk/bpf/c/inc/sol/inc/assert.inc | 47 ---- sdk/bpf/c/inc/sol/inc/big_mod_exp.inc | 23 -- sdk/bpf/c/inc/sol/inc/blake3.inc | 30 -- sdk/bpf/c/inc/sol/inc/cpi.inc | 117 -------- sdk/bpf/c/inc/sol/inc/keccak.inc | 30 -- sdk/bpf/c/inc/sol/inc/log.inc | 103 ------- sdk/bpf/c/inc/sol/inc/pubkey.inc | 107 ------- sdk/bpf/c/inc/sol/inc/return_data.inc | 41 --- sdk/bpf/c/inc/sol/inc/secp256k1.inc | 41 --- sdk/bpf/c/inc/sol/inc/sha.inc | 30 -- sdk/bpf/c/inc/sol/keccak.h | 39 --- sdk/bpf/c/inc/sol/log.h | 139 --------- sdk/bpf/c/inc/sol/pubkey.h | 134 --------- sdk/bpf/c/inc/sol/return_data.h | 59 ---- sdk/bpf/c/inc/sol/secp256k1.h | 50 ---- sdk/bpf/c/inc/sol/sha.h | 39 --- sdk/bpf/c/inc/sol/string.h | 116 -------- sdk/bpf/c/inc/sol/types.h | 141 ---------- sdk/bpf/c/inc/solana_sdk.h | 23 -- sdk/bpf/c/inc/stdio.h | 4 - sdk/bpf/c/inc/stdlib.h | 2 - sdk/bpf/c/inc/string.h | 7 - sdk/bpf/c/inc/sys/param.h | 1 - sdk/bpf/c/inc/wchar.h | 1 - sdk/bpf/env.sh | 16 -- sdk/bpf/scripts/dump.sh | 46 --- sdk/bpf/scripts/install.sh | 139 --------- sdk/bpf/scripts/objcopy.sh | 6 - sdk/bpf/scripts/package.sh | 19 -- sdk/bpf/scripts/strip.sh | 23 -- sdk/cargo-build-bpf/.gitignore | 1 - sdk/cargo-build-bpf/Cargo.toml | 21 -- sdk/cargo-build-bpf/src/main.rs | 58 ---- sdk/cargo-test-bpf/Cargo.toml | 14 - sdk/cargo-test-bpf/src/main.rs | 61 ---- 54 files changed, 2882 deletions(-) delete mode 100755 cargo-build-bpf delete mode 100755 cargo-test-bpf delete mode 100644 sdk/bpf/.gitignore delete mode 100644 sdk/bpf/c/README.md delete mode 100644 sdk/bpf/c/bpf.ld delete mode 100644 sdk/bpf/c/bpf.mk delete mode 100644 sdk/bpf/c/inc/deserialize_deprecated.h delete mode 100644 sdk/bpf/c/inc/sol/alt_bn128.h delete mode 100644 sdk/bpf/c/inc/sol/assert.h delete mode 100644 sdk/bpf/c/inc/sol/big_mod_exp.h delete mode 100644 sdk/bpf/c/inc/sol/blake3.h delete mode 100644 sdk/bpf/c/inc/sol/constants.h delete mode 100644 sdk/bpf/c/inc/sol/cpi.h delete mode 100644 sdk/bpf/c/inc/sol/deserialize.h delete mode 100644 sdk/bpf/c/inc/sol/deserialize_deprecated.h delete mode 100644 sdk/bpf/c/inc/sol/entrypoint.h delete mode 100644 sdk/bpf/c/inc/sol/inc/alt_bn128.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/assert.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/big_mod_exp.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/blake3.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/cpi.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/keccak.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/log.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/pubkey.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/return_data.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/secp256k1.inc delete mode 100644 sdk/bpf/c/inc/sol/inc/sha.inc delete mode 100644 sdk/bpf/c/inc/sol/keccak.h delete mode 100644 sdk/bpf/c/inc/sol/log.h delete mode 100644 sdk/bpf/c/inc/sol/pubkey.h delete mode 100644 sdk/bpf/c/inc/sol/return_data.h delete mode 100644 sdk/bpf/c/inc/sol/secp256k1.h delete mode 100644 sdk/bpf/c/inc/sol/sha.h delete mode 100644 sdk/bpf/c/inc/sol/string.h delete mode 100644 sdk/bpf/c/inc/sol/types.h delete mode 100644 sdk/bpf/c/inc/solana_sdk.h delete mode 100644 sdk/bpf/c/inc/stdio.h delete mode 100644 sdk/bpf/c/inc/stdlib.h delete mode 100644 sdk/bpf/c/inc/string.h delete mode 100644 sdk/bpf/c/inc/sys/param.h delete mode 100644 sdk/bpf/c/inc/wchar.h delete mode 100644 sdk/bpf/env.sh delete mode 100755 sdk/bpf/scripts/dump.sh delete mode 100755 sdk/bpf/scripts/install.sh delete mode 100755 sdk/bpf/scripts/objcopy.sh delete mode 100755 sdk/bpf/scripts/package.sh delete mode 100755 sdk/bpf/scripts/strip.sh delete mode 100644 sdk/cargo-build-bpf/.gitignore delete mode 100644 sdk/cargo-build-bpf/Cargo.toml delete mode 100644 sdk/cargo-build-bpf/src/main.rs delete mode 100644 sdk/cargo-test-bpf/Cargo.toml delete mode 100644 sdk/cargo-test-bpf/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 31e8a9fd287f37..b997aa12670df0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5761,14 +5761,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "solana-cargo-build-bpf" -version = "2.1.0" -dependencies = [ - "log", - "solana-logger", -] - [[package]] name = "solana-cargo-build-sbf" version = "2.1.0" @@ -5790,10 +5782,6 @@ dependencies = [ "tar", ] -[[package]] -name = "solana-cargo-test-bpf" -version = "2.1.0" - [[package]] name = "solana-cargo-test-sbf" version = "2.1.0" diff --git a/Cargo.toml b/Cargo.toml index 67b73b5cbd114e..c49cf19f2fac82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,9 +98,7 @@ members = [ "sanitize", "sdk", "sdk/atomic-u64", - "sdk/cargo-build-bpf", "sdk/cargo-build-sbf", - "sdk/cargo-test-bpf", "sdk/cargo-test-sbf", "sdk/gen-headers", "sdk/macro", diff --git a/cargo-build-bpf b/cargo-build-bpf deleted file mode 100755 index 0ef191aa1dadbf..00000000000000 --- a/cargo-build-bpf +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -here=$(dirname "$0") - -maybe_bpf_sdk="--bpf-sdk $here/sdk/bpf" -for a in "$@"; do - if [[ $a = --bpf-sdk ]]; then - maybe_bpf_sdk= - fi -done - -set -ex -if [[ ! -f "$here"/sdk/bpf/syscalls.txt ]]; then - cargo build --manifest-path "$here"/programs/bpf_loader/gen-syscall-list/Cargo.toml -fi -if [[ ! -f "$here"/target/debug/cargo-build-sbf ]]; then - cargo build --manifest-path "$here"/sdk/cargo-build-sbf/Cargo.toml -fi -exec cargo run --manifest-path "$here"/sdk/cargo-build-bpf/Cargo.toml -- $maybe_bpf_sdk "$@" diff --git a/cargo-test-bpf b/cargo-test-bpf deleted file mode 100755 index 78b5a3673930fd..00000000000000 --- a/cargo-test-bpf +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -here=$(dirname "$0") - -maybe_bpf_sdk="--bpf-sdk $here/sdk/bpf" -for a in "$@"; do - if [[ $a = --bpf-sdk ]]; then - maybe_bpf_sdk= - fi -done - -export CARGO_BUILD_BPF="$here"/cargo-build-bpf -set -x -if [[ ! -f "$here"/target/debug/cargo-build-sbf ]]; then - cargo build --manifest-path "$here"/sdk/cargo-build-sbf/Cargo.toml -fi -if [[ ! -f "$here"/target/debug/cargo-test-sbf ]]; then - cargo build --manifest-path "$here"/sdk/cargo-test-sbf/Cargo.toml -fi -exec cargo run --manifest-path "$here"/sdk/cargo-test-bpf/Cargo.toml -- $maybe_bpf_sdk "$@" diff --git a/sdk/bpf/.gitignore b/sdk/bpf/.gitignore deleted file mode 100644 index e9ab3169be5448..00000000000000 --- a/sdk/bpf/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/dependencies/criterion* -/dependencies/hashbrown* -/dependencies/llvm-native* -/dependencies/rust-bpf-sysroot* -/dependencies/bpf-tools* -/dependencies/sbf-tools* -/dependencies/xargo* -/dependencies/bin* -/dependencies/.crates.toml -/dependencies/.crates2.json -/syscalls.txt diff --git a/sdk/bpf/c/README.md b/sdk/bpf/c/README.md deleted file mode 100644 index f2c3a1022b0125..00000000000000 --- a/sdk/bpf/c/README.md +++ /dev/null @@ -1,42 +0,0 @@ -## Development - -### Quick start -To get started create a `makefile` containing: -```make -include path/to/bpf.mk -``` -and `src/program.c` containing: -```c -#include - -extern uint64_t entrypoint(const uint8_t *input) { - SolAccountInfo ka[1]; - SolParameters params = (SolParameters) { .ka = ka }; - - if (!sol_deserialize(input, ¶ms, SOL_ARRAY_SIZE(ka))) { - return ERROR_INVALID_ARGUMENT; - } - return SUCCESS; -} -``` - -Then run `make` to build `out/program.o`. -Run `make help` for more details. - -### Unit tests -Built-in support for unit testing is provided by the -[Criterion](https://criterion.readthedocs.io/en/master/index.html) test framework. -To get started create the file `test/example.c` containing: -```c -#include -#include "../src/program.c" - -Test(test_suite_name, test_case_name) { - cr_assert(true); -} -``` -Then run `make test`. - -### Limitations -* Programs must be fully contained within a single .c file -* No libc is available but `solana_sdk.h` provides a minimal set of primitives diff --git a/sdk/bpf/c/bpf.ld b/sdk/bpf/c/bpf.ld deleted file mode 100644 index 262fd549324e8e..00000000000000 --- a/sdk/bpf/c/bpf.ld +++ /dev/null @@ -1,24 +0,0 @@ -PHDRS -{ - text PT_LOAD ; - rodata PT_LOAD ; - data PT_LOAD ; - dynamic PT_DYNAMIC ; -} - -SECTIONS -{ - . = SIZEOF_HEADERS; - .text : { *(.text*) } :text - .rodata : { *(.rodata*) } :rodata - .data.rel.ro : { *(.data.rel.ro*) } :rodata - .dynamic : { *(.dynamic) } :dynamic - .dynsym : { *(.dynsym) } :data - .dynstr : { *(.dynstr) } :data - .rel.dyn : { *(.rel.dyn) } :data - /DISCARD/ : { - *(.eh_frame*) - *(.gnu.hash*) - *(.hash*) - } -} diff --git a/sdk/bpf/c/bpf.mk b/sdk/bpf/c/bpf.mk deleted file mode 100644 index 7f52f7b3080e30..00000000000000 --- a/sdk/bpf/c/bpf.mk +++ /dev/null @@ -1,313 +0,0 @@ -LOCAL_PATH := $(dir $(lastword $(MAKEFILE_LIST))) -INSTALL_SH := $(abspath $(LOCAL_PATH)/../scripts/install.sh) - -all: -.PHONY: help all clean - -ifneq ($(V),1) -_@ :=@ -endif - -INC_DIRS ?= -SRC_DIR ?= ./src -TEST_PREFIX ?= test_ -OUT_DIR ?= ./out -OS := $(shell uname) - -LLVM_DIR = $(LOCAL_PATH)../dependencies/bpf-tools/llvm -LLVM_SYSTEM_INC_DIRS := $(LLVM_DIR)/lib/clang/15.0.4/include -COMPILER_RT_DIR = $(LOCAL_PATH)../dependencies/bpf-tools/rust/lib/rustlib/bpfel-unknown-unknown/lib -STD_INC_DIRS := $(LLVM_DIR)/include -STD_LIB_DIRS := $(LLVM_DIR)/lib - -ifdef LLVM_DIR -CC := $(LLVM_DIR)/bin/clang -CXX := $(LLVM_DIR)/bin/clang++ -LLD := $(LLVM_DIR)/bin/ld.lld -OBJ_DUMP := $(LLVM_DIR)/bin/llvm-objdump -READ_ELF := $(LLVM_DIR)/bin/llvm-readelf -endif - -SYSTEM_INC_DIRS := \ - $(LOCAL_PATH)inc \ - $(LLVM_SYSTEM_INC_DIRS) \ - -C_FLAGS := \ - -Werror \ - -O2 \ - -fno-builtin \ - -std=c17 \ - $(addprefix -isystem,$(SYSTEM_INC_DIRS)) \ - $(addprefix -I,$(STD_INC_DIRS)) \ - $(addprefix -I,$(INC_DIRS)) \ - -ifeq ($(SOL_SBFV2),1) -C_FLAGS := \ - $(C_FLAGS) \ - -DSOL_SBFV2=1 -endif - -CXX_FLAGS := \ - $(C_FLAGS) \ - -std=c++17 \ - -BPF_C_FLAGS := \ - $(C_FLAGS) \ - -target bpf \ - -fPIC \ - -march=bpfel+solana - -BPF_CXX_FLAGS := \ - $(CXX_FLAGS) \ - -target bpf \ - -fPIC \ - -fomit-frame-pointer \ - -fno-exceptions \ - -fno-asynchronous-unwind-tables \ - -fno-unwind-tables \ - -march=bpfel+solana - -BPF_LLD_FLAGS := \ - -z notext \ - -shared \ - --Bdynamic \ - $(LOCAL_PATH)bpf.ld \ - --entry entrypoint \ - -L $(STD_LIB_DIRS) \ - -lc \ - -ifeq ($(SOL_SBFV2),1) -BPF_LLD_FLAGS := \ - $(BPF_LLD_FLAGS) \ - --pack-dyn-relocs=relr -endif - -OBJ_DUMP_FLAGS := \ - --source \ - --disassemble \ - -READ_ELF_FLAGS := \ - --all \ - -TESTFRAMEWORK_RPATH := $(abspath $(LOCAL_PATH)../dependencies/criterion/lib) -TESTFRAMEWORK_FLAGS := \ - -DSOL_TEST \ - -isystem $(LOCAL_PATH)../dependencies/criterion/include \ - -L $(LOCAL_PATH)../dependencies/criterion/lib \ - -rpath $(TESTFRAMEWORK_RPATH) \ - -lcriterion \ - -MACOS_ADJUST_TEST_DYLIB := \ -$(if $(filter $(OS),Darwin),\ - $(_@)install_name_tool -change libcriterion.3.dylib $(TESTFRAMEWORK_RPATH)/libcriterion.3.dylib, \ - : \ -) - -TEST_C_FLAGS := \ - $(C_FLAGS) \ - $(TESTFRAMEWORK_FLAGS) \ - -TEST_CXX_FLAGS := \ - $(CXX_FLAGS) \ - $(TESTFRAMEWORK_FLAGS) \ - -help: - @echo '' - @echo 'BPF Program makefile' - @echo '' - @echo 'This makefile will build BPF Programs from C or C++ source files into ELFs' - @echo '' - @echo 'Assumptions:' - @echo ' - Programs are located in the source directory: $(SRC_DIR)/' - @echo ' - Programs are named by their directory name (eg. directory name:src/foo/ -> program name:foo)' - @echo ' - Tests are located in their corresponding program directory and must being with "test_"' - @echo ' - Output files will be placed in the directory: $(OUT_DIR)' - @echo '' - @echo 'User settings' - @echo ' - The following setting are overridable on the command line, default values shown:' - @echo ' - Show commands while building: V=1' - @echo ' V=$(V)' - @echo ' - List of include directories:' - @echo ' INC_DIRS=$(INC_DIRS)' - @echo ' - List of system include directories:' - @echo ' SYSTEM_INC_DIRS=$(SYSTEM_INC_DIRS)' - @echo ' - List of standard library include directories:' - @echo ' STD_INC_DIRS=$(STD_INC_DIRS)' - @echo ' - List of standard library archive directories:' - @echo ' STD_LIB_DIRS=$(STD_LIB_DIRS)' - @echo ' - Location of source directories:' - @echo ' SRC_DIR=$(SRC_DIR)' - @echo ' - Location to place output files:' - @echo ' OUT_DIR=$(OUT_DIR)' - @echo ' - Location of LLVM:' - @echo ' LLVM_DIR=$(LLVM_DIR)' - @echo '' - @echo 'Usage:' - @echo ' - make help - This help message' - @echo ' - make all - Build all the programs and tests, run the tests' - @echo ' - make programs - Build all the programs' - @echo ' - make tests - Build and run all tests' - @echo ' - make dump_ - Dump the contents of the program to stdout' - @echo ' - make readelf_ - Display information about the ELF binary' - @echo ' - make - Build a single program by name' - @echo ' - make - Build and run a single test by name' - @echo '' - @echo 'Available programs:' - $(foreach name, $(PROGRAM_NAMES), @echo ' - $(name)'$(\n)) - @echo '' - @echo 'Available tests:' - $(foreach name, $(TEST_NAMES), @echo ' - $(name)'$(\n)) - @echo '' - @echo 'Example:' - @echo ' - Assuming a program named foo (src/foo/foo.c)' - @echo ' - make foo' - @echo ' - make dump_foo' - @echo '' - -define C_RULE -$1: $2 - @echo "[cc] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(CC) $(BPF_C_FLAGS) -o $1 -c $2 -endef - -define CC_RULE -$1: $2 - @echo "[cxx] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(CXX) $(BPF_CXX_FLAGS) -o $1 -c $2 -endef - -define D_RULE -$1: $2 $(LOCAL_PATH)/bpf.mk - @echo "[GEN] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(CC) -M -MT '$(basename $1).o' $(BPF_C_FLAGS) $2 | sed 's,\($(basename $1)\)\.o[ :]*,\1.o $1 : ,g' > $1 -endef - -define DXX_RULE -$1: $2 $(LOCAL_PATH)/bpf.mk - @echo "[GEN] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(CXX) -M -MT '$(basename $1).o' $(BPF_CXX_FLAGS) $2 | sed 's,\($(basename $1)\)\.o[ :]*,\1.o $1 : ,g' > $1 -endef - -define O_RULE -$1: $2 - @echo "[llc] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(LLC) $(BPF_LLC_FLAGS) -o $1 $2 -endef - -define SO_RULE -$1: $2 - @echo "[lld] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(LLD) $(BPF_LLD_FLAGS) -o $1 $2 $(COMPILER_RT_DIR)/libcompiler_builtins-*.rlib -ifeq (,$(wildcard $(subst .so,-keypair.json,$1))) - $(_@)solana-keygen new --no-passphrase --silent -o $(subst .so,-keypair.json,$1) -endif - @echo To deploy this program: - @echo $$$$ solana program deploy $(abspath $1) -endef - -define TEST_C_RULE -$1: $2 - @echo "[test cc] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(CC) $(TEST_C_FLAGS) -o $1 $2 - $(_@)$(MACOS_ADJUST_TEST_DYLIB) $1 -endef - -define TEST_CC_RULE -$1: $2 - @echo "[test cxx] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(CXX) $(TEST_CXX_FLAGS) -o $1 $2 - $(_@)$(MACOS_ADJUST_TEST_DYLIB) $1 -endef - -define TEST_D_RULE -$1: $2 $(LOCAL_PATH)/bpf.mk - @echo "[GEN] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(CC) -M -MT '$(basename $1)' $(TEST_C_FLAGS) $2 | sed 's,\($(basename $1)\)[ :]*,\1 $1 : ,g' > $1 -endef - -define TEST_DXX_RULE -$1: $2 $(LOCAL_PATH)/bpf.mk - @echo "[GEN] $1 ($2)" - $(_@)mkdir -p $(dir $1) - $(_@)$(CXX) -M -MT '$(basename $1)' $(TEST_CXX_FLAGS) $2 | sed 's,\($(basename $1)\)[ :]*,\1 $1 : ,g' > $1 -endef - -define TEST_EXEC_RULE -$1: $2 - LD_LIBRARY_PATH=$(TESTFRAMEWORK_RPATH) \ - $2$(\n) -endef - -.PHONY: $(INSTALL_SH) -$(INSTALL_SH): - $(_@)$(INSTALL_SH) - -PROGRAM_NAMES := $(notdir $(basename $(wildcard $(SRC_DIR)/*))) - -define \n - - -endef - -all: programs tests - -$(foreach PROGRAM, $(PROGRAM_NAMES), \ - $(eval -include $(wildcard $(OUT_DIR)/$(PROGRAM)/*.d)) \ - \ - $(eval $(PROGRAM): %: $(addprefix $(OUT_DIR)/, %.so)) \ - $(eval $(PROGRAM)_SRCS := \ - $(addprefix $(SRC_DIR)/$(PROGRAM)/, \ - $(filter-out $(TEST_PREFIX)%,$(notdir $(wildcard $(SRC_DIR)/$(PROGRAM)/*.c $(SRC_DIR)/$(PROGRAM)/*.cc))))) \ - $(eval $(PROGRAM)_OBJS := $(subst $(SRC_DIR), $(OUT_DIR), \ - $(patsubst %.c,%.o, \ - $(patsubst %.cc,%.o,$($(PROGRAM)_SRCS))))) \ - $(eval $($(PROGRAM)_SRCS): $(INSTALL_SH)) \ - $(eval $(call SO_RULE,$(OUT_DIR)/$(PROGRAM).so,$($(PROGRAM)_OBJS))) \ - $(foreach _,$(filter %.c,$($(PROGRAM)_SRCS)), \ - $(eval $(call D_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.c=%.d)),$_)) \ - $(eval $(call C_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.c=%.o)),$_))) \ - $(foreach _,$(filter %.cc,$($(PROGRAM)_SRCS)), \ - $(eval $(call DXX_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.cc=%.d)),$_)) \ - $(eval $(call CC_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.cc=%.o)),$_))) \ - \ - $(eval TESTS := $(notdir $(basename $(wildcard $(SRC_DIR)/$(PROGRAM)/$(TEST_PREFIX)*.c)))) \ - $(eval $(TESTS) : %: $(addprefix $(OUT_DIR)/$(PROGRAM)/, %)) \ - $(eval TEST_NAMES := $(TEST_NAMES) $(TESTS)) \ - $(foreach TEST, $(TESTS), \ - $(eval $(TEST)_SRCS := \ - $(addprefix $(SRC_DIR)/$(PROGRAM)/, \ - $(notdir $(wildcard $(SRC_DIR)/$(PROGRAM)/$(TEST).c $(SRC_DIR)/$(PROGRAM)/$(TEST).cc)))) \ - $(eval $($(TEST)_SRCS): $(INSTALL_SH)) \ - $(foreach _,$(filter %.c,$($(TEST)_SRCS)), \ - $(eval $(call TEST_D_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.c=%.d)),$_)) \ - $(eval $(call TEST_C_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.c=%)),$_))) \ - $(foreach _,$(filter %.cc, $($(TEST)_SRCS)), \ - $(eval $(call TEST_DXX_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.cc=%.d)),$_)) \ - $(eval $(call TEST_CC_RULE,$(subst $(SRC_DIR),$(OUT_DIR),$(_:%.cc=%)),$_))) \ - $(eval $(call TEST_EXEC_RULE,$(TEST),$(addprefix $(OUT_DIR)/$(PROGRAM)/, $(TEST)))) \ - ) \ -) - -.PHONY: $(PROGRAM_NAMES) -programs: $(PROGRAM_NAMES) - -.PHONY: $(TEST_NAMES) -tests: $(TEST_NAMES) - -dump_%: % - $(_@)$(OBJ_DUMP) $(OBJ_DUMP_FLAGS) $(addprefix $(OUT_DIR)/, $(addsuffix .so, $<)) - -readelf_%: % - $(_@)$(READ_ELF) $(READ_ELF_FLAGS) $(addprefix $(OUT_DIR)/, $(addsuffix .so, $<)) - -clean: - rm -rf $(OUT_DIR) diff --git a/sdk/bpf/c/inc/deserialize_deprecated.h b/sdk/bpf/c/inc/deserialize_deprecated.h deleted file mode 100644 index db9c6de8aa402c..00000000000000 --- a/sdk/bpf/c/inc/deserialize_deprecated.h +++ /dev/null @@ -1 +0,0 @@ -#include \ No newline at end of file diff --git a/sdk/bpf/c/inc/sol/alt_bn128.h b/sdk/bpf/c/inc/sol/alt_bn128.h deleted file mode 100644 index 1d49b454c1fa9e..00000000000000 --- a/sdk/bpf/c/inc/sol/alt_bn128.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once -/** - * @brief Solana bn128 elliptic curve addition, multiplication, and pairing -**/ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Addition on elliptic curves alt_bn128 - * - * @param group_op ... - * @param input ... - * @param input_size ... - * @param result 64 byte array to hold the result. ... - * @return 0 if executed successfully - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/sbf/c/inc/sol/inc/alt_bn128.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_alt_bn128( - const uint64_t *group_op, - const uint8_t *input, - const uint64_t input_size, - uint8_t *result -); -#else -typedef uint64_t(*sol_alt_bn128_pointer_type)( - const uint64_t *group_op, - const uint8_t *input, - const uint64_t input_size, - uint8_t *result -); -static uint64_t sol_alt_bn128( - const uint64_t *group_op arg1, - const uint8_t *input arg2, - const uint64_t input_size arg3, - uint8_t *result - arg4) { - sol_alt_bn128_pointer_type sol_alt_bn128_pointer = (sol_alt_bn128_pointer_type) 2551807235; - return sol_alt_bn128_pointer(arg1, arg2, arg3, arg4); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/assert.h b/sdk/bpf/c/inc/sol/assert.h deleted file mode 100644 index 77217d1025989b..00000000000000 --- a/sdk/bpf/c/inc/sol/assert.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -/** - * @brief Solana assert and panic utilities - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Panics - * - * Prints the line number where the panic occurred and then causes - * the BPF VM to immediately halt execution. No accounts' data are updated - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/assert.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -void sol_panic_(const char *, uint64_t, uint64_t, uint64_t); -#else -typedef void(*sol_panic__pointer_type)(const char *, uint64_t, uint64_t, uint64_t); -static void sol_panic_(const char * arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) { - sol_panic__pointer_type sol_panic__pointer = (sol_panic__pointer_type) 1751159739; - sol_panic__pointer(arg1, arg2, arg3, arg4); -} -#endif -#define sol_panic() sol_panic_(__FILE__, sizeof(__FILE__), __LINE__, 0) - -/** - * Asserts - */ -#define sol_assert(expr) \ -if (!(expr)) { \ - sol_panic(); \ -} - -#ifdef SOL_TEST -/** - * Stub functions when building tests - */ -#include -#include - -void sol_panic_(const char *file, uint64_t len, uint64_t line, uint64_t column) { - printf("Panic in %s at %d:%d\n", file, line, column); - abort(); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/big_mod_exp.h b/sdk/bpf/c/inc/sol/big_mod_exp.h deleted file mode 100644 index b90c66a1930b80..00000000000000 --- a/sdk/bpf/c/inc/sol/big_mod_exp.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -/** - * @brief Solana big_mod_exp system call -**/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Big integer modular exponentiation - * - * @param bytes Pointer to BigModExpParam struct - * @param result 32 byte array to hold the result - * @return 0 if executed successfully - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/big_mod_exp.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_big_mod_exp(const uint8_t *, uint8_t *); -#else -typedef uint64_t(*sol_big_mod_exp_pointer_type)(const uint8_t *, uint8_t *); -static uint64_t sol_big_mod_exp(const uint8_t * arg1, uint8_t * arg2) { - sol_big_mod_exp_pointer_type sol_big_mod_exp_pointer = (sol_big_mod_exp_pointer_type) 2014202901; - return sol_big_mod_exp_pointer(arg1, arg2); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/blake3.h b/sdk/bpf/c/inc/sol/blake3.h deleted file mode 100644 index 04c12989e98400..00000000000000 --- a/sdk/bpf/c/inc/sol/blake3.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -/** - * @brief Solana Blake3 system call - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Length of a Blake3 hash result - */ -#define BLAKE3_RESULT_LENGTH 32 - -/** - * Blake3 - * - * @param bytes Array of byte arrays - * @param bytes_len Number of byte arrays - * @param result 32 byte array to hold the result - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/blake3.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_blake3(const SolBytes *, int, const uint8_t *); -#else -typedef uint64_t(*sol_blake3_pointer_type)(const SolBytes *, int, const uint8_t *); -static uint64_t sol_blake3(const SolBytes * arg1, int arg2, const uint8_t * arg3) { - sol_blake3_pointer_type sol_blake3_pointer = (sol_blake3_pointer_type) 390877474; - return sol_blake3_pointer(arg1, arg2, arg3); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/constants.h b/sdk/bpf/c/inc/sol/constants.h deleted file mode 100644 index dcb7785bd1344c..00000000000000 --- a/sdk/bpf/c/inc/sol/constants.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -/** - * @brief Solana constants - */ - -/** - * The Solana runtime provides a memory region that is available to programs at - * a fixed virtual address and length. The builtin functions `sol_calloc` and - * `sol_free` call into the Solana runtime to allocate from this memory region - * for heap operations. Because the memory region is directly available to - * programs another option is a program can implement their own heap directly on - * top of that region. If a program chooses to implement their own heap they - * should not call the builtin heap functions because they will conflict. - * `HEAP_START_ADDRESS` and `HEAP_LENGTH` specify the memory region's start - * virtual address and length. - */ -#define HEAP_START_ADDRESS (uint64_t)0x300000000 -#define HEAP_LENGTH (uint64_t)(32 * 1024) diff --git a/sdk/bpf/c/inc/sol/cpi.h b/sdk/bpf/c/inc/sol/cpi.h deleted file mode 100644 index b3748cff2240f9..00000000000000 --- a/sdk/bpf/c/inc/sol/cpi.h +++ /dev/null @@ -1,138 +0,0 @@ -#pragma once -/** - * @brief Solana Cross-Program Invocation - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Maximum CPI instruction data size. 10 KiB was chosen to ensure that CPI - * instructions are not more limited than transaction instructions if the size - * of transactions is doubled in the future. - */ -static const uint64_t MAX_CPI_INSTRUCTION_DATA_LEN = 10240; - -/** - * Maximum CPI instruction accounts. 255 was chosen to ensure that instruction - * accounts are always within the maximum instruction account limit for BPF - * program instructions. - */ -static const uint8_t MAX_CPI_INSTRUCTION_ACCOUNTS = 255; - -/** - * Maximum number of account info structs that can be used in a single CPI - * invocation. A limit on account info structs is effectively the same as - * limiting the number of unique accounts. 128 was chosen to match the max - * number of locked accounts per transaction (MAX_TX_ACCOUNT_LOCKS). - */ -static const uint16_t MAX_CPI_ACCOUNT_INFOS = 128; - -/** - * Account Meta - */ -typedef struct { - SolPubkey *pubkey; /** An account's public key */ - bool is_writable; /** True if the `pubkey` can be loaded as a read-write account */ - bool is_signer; /** True if an Instruction requires a Transaction signature matching `pubkey` */ -} SolAccountMeta; - -/** - * Instruction - */ -typedef struct { - SolPubkey *program_id; /** Pubkey of the instruction processor that executes this instruction */ - SolAccountMeta *accounts; /** Metadata for what accounts should be passed to the instruction processor */ - uint64_t account_len; /** Number of SolAccountMetas */ - uint8_t *data; /** Opaque data passed to the instruction processor */ - uint64_t data_len; /** Length of the data in bytes */ -} SolInstruction; - -/** - * Internal cross-program invocation function - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/cpi.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_invoke_signed_c( - const SolInstruction *, - const SolAccountInfo *, - int, - const SolSignerSeeds *, - int -); -#else -typedef uint64_t(*sol_invoke_signed_c_pointer_type)( - const SolInstruction *, - const SolAccountInfo *, - int, - const SolSignerSeeds *, - int -); -static uint64_t sol_invoke_signed_c( - const SolInstruction * arg1, - const SolAccountInfo * arg2, - int arg3, - const SolSignerSeeds * arg4, - int - arg5) { - sol_invoke_signed_c_pointer_type sol_invoke_signed_c_pointer = (sol_invoke_signed_c_pointer_type) 2720767109; - return sol_invoke_signed_c_pointer(arg1, arg2, arg3, arg4, arg5); -} -#endif - -/** - * Invoke another program and sign for some of the keys - * - * @param instruction Instruction to process - * @param account_infos Accounts used by instruction - * @param account_infos_len Length of account_infos array - * @param seeds Seed bytes used to sign program accounts - * @param seeds_len Length of the seeds array - */ -static uint64_t sol_invoke_signed( - const SolInstruction *instruction, - const SolAccountInfo *account_infos, - int account_infos_len, - const SolSignerSeeds *signers_seeds, - int signers_seeds_len -) { - return sol_invoke_signed_c( - instruction, - account_infos, - account_infos_len, - signers_seeds, - signers_seeds_len - ); -} -/** - * Invoke another program - * - * @param instruction Instruction to process - * @param account_infos Accounts used by instruction - * @param account_infos_len Length of account_infos array -*/ -static uint64_t sol_invoke( - const SolInstruction *instruction, - const SolAccountInfo *account_infos, - int account_infos_len -) { - const SolSignerSeeds signers_seeds[] = {{}}; - return sol_invoke_signed( - instruction, - account_infos, - account_infos_len, - signers_seeds, - 0 - ); -} - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/deserialize.h b/sdk/bpf/c/inc/sol/deserialize.h deleted file mode 100644 index e5060549581dbe..00000000000000 --- a/sdk/bpf/c/inc/sol/deserialize.h +++ /dev/null @@ -1,137 +0,0 @@ -#pragma once -/** - * @brief Solana BPF loader deserializer to be used when deploying - * a program with `BPFLoader2111111111111111111111111111111111` or - * `BPFLoaderUpgradeab1e11111111111111111111111` - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Maximum number of bytes a program may add to an account during a single realloc - */ -#define MAX_PERMITTED_DATA_INCREASE (1024 * 10) - -/** - * De-serializes the input parameters into usable types - * - * Use this function to deserialize the buffer passed to the program entrypoint - * into usable types. This function does not perform copy deserialization, - * instead it populates the pointers and lengths in SolAccountInfo and data so - * that any modification to lamports or account data take place on the original - * buffer. Doing so also eliminates the need to serialize back into the buffer - * at the end of the program. - * - * @param input Source buffer containing serialized input parameters - * @param params Pointer to a SolParameters structure - * @return Boolean true if successful. - */ -static bool sol_deserialize( - const uint8_t *input, - SolParameters *params, - uint64_t ka_num -) { - if (NULL == input || NULL == params) { - return false; - } - params->ka_num = *(uint64_t *) input; - input += sizeof(uint64_t); - - for (int i = 0; i < params->ka_num; i++) { - uint8_t dup_info = input[0]; - input += sizeof(uint8_t); - - if (i >= ka_num) { - if (dup_info == UINT8_MAX) { - input += sizeof(uint8_t); - input += sizeof(uint8_t); - input += sizeof(uint8_t); - input += 4; // padding - input += sizeof(SolPubkey); - input += sizeof(SolPubkey); - input += sizeof(uint64_t); - uint64_t data_len = *(uint64_t *) input; - input += sizeof(uint64_t); - input += data_len; - input += MAX_PERMITTED_DATA_INCREASE; - input = (uint8_t*)(((uint64_t)input + 8 - 1) & ~(8 - 1)); // padding - input += sizeof(uint64_t); - } else { - input += 7; // padding - } - continue; - } - if (dup_info == UINT8_MAX) { - // is signer? - params->ka[i].is_signer = *(uint8_t *) input != 0; - input += sizeof(uint8_t); - - // is writable? - params->ka[i].is_writable = *(uint8_t *) input != 0; - input += sizeof(uint8_t); - - // executable? - params->ka[i].executable = *(uint8_t *) input; - input += sizeof(uint8_t); - - input += 4; // padding - - // key - params->ka[i].key = (SolPubkey *) input; - input += sizeof(SolPubkey); - - // owner - params->ka[i].owner = (SolPubkey *) input; - input += sizeof(SolPubkey); - - // lamports - params->ka[i].lamports = (uint64_t *) input; - input += sizeof(uint64_t); - - // account data - params->ka[i].data_len = *(uint64_t *) input; - input += sizeof(uint64_t); - params->ka[i].data = (uint8_t *) input; - input += params->ka[i].data_len; - input += MAX_PERMITTED_DATA_INCREASE; - input = (uint8_t*)(((uint64_t)input + 8 - 1) & ~(8 - 1)); // padding - - // rent epoch - params->ka[i].rent_epoch = *(uint64_t *) input; - input += sizeof(uint64_t); - } else { - params->ka[i].is_signer = params->ka[dup_info].is_signer; - params->ka[i].is_writable = params->ka[dup_info].is_writable; - params->ka[i].executable = params->ka[dup_info].executable; - params->ka[i].key = params->ka[dup_info].key; - params->ka[i].owner = params->ka[dup_info].owner; - params->ka[i].lamports = params->ka[dup_info].lamports; - params->ka[i].data_len = params->ka[dup_info].data_len; - params->ka[i].data = params->ka[dup_info].data; - params->ka[i].rent_epoch = params->ka[dup_info].rent_epoch; - input += 7; // padding - } - } - - params->data_len = *(uint64_t *) input; - input += sizeof(uint64_t); - params->data = input; - input += params->data_len; - - params->program_id = (SolPubkey *) input; - input += sizeof(SolPubkey); - - return true; -} - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/deserialize_deprecated.h b/sdk/bpf/c/inc/sol/deserialize_deprecated.h deleted file mode 100644 index 4a38eaed678530..00000000000000 --- a/sdk/bpf/c/inc/sol/deserialize_deprecated.h +++ /dev/null @@ -1,119 +0,0 @@ -#pragma once -/** - * @brief Solana deprecated BPF loader deserializer to be used when deploying - * a program with `BPFLoader1111111111111111111111111111111111` - */ - - #include - #include - #include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * De-serializes the input parameters into usable types - * - * Use this function to deserialize the buffer passed to the program entrypoint - * into usable types. This function does not perform copy deserialization, - * instead it populates the pointers and lengths in SolAccountInfo and data so - * that any modification to lamports or account data take place on the original - * buffer. Doing so also eliminates the need to serialize back into the buffer - * at the end of the program. - * - * @param input Source buffer containing serialized input parameters - * @param params Pointer to a SolParameters structure - * @return Boolean true if successful. - */ -static bool sol_deserialize_deprecated( - const uint8_t *input, - SolParameters *params, - uint64_t ka_num -) { - if (NULL == input || NULL == params) { - return false; - } - params->ka_num = *(uint64_t *) input; - input += sizeof(uint64_t); - - for (int i = 0; i < params->ka_num; i++) { - uint8_t dup_info = input[0]; - input += sizeof(uint8_t); - - if (i >= ka_num) { - if (dup_info == UINT8_MAX) { - input += sizeof(uint8_t); - input += sizeof(uint8_t); - input += sizeof(SolPubkey); - input += sizeof(uint64_t); - input += *(uint64_t *) input; - input += sizeof(uint64_t); - input += sizeof(SolPubkey); - input += sizeof(uint8_t); - input += sizeof(uint64_t); - } - continue; - } - if (dup_info == UINT8_MAX) { - // is signer? - params->ka[i].is_signer = *(uint8_t *) input != 0; - input += sizeof(uint8_t); - - // is writable? - params->ka[i].is_writable = *(uint8_t *) input != 0; - input += sizeof(uint8_t); - - // key - params->ka[i].key = (SolPubkey *) input; - input += sizeof(SolPubkey); - - // lamports - params->ka[i].lamports = (uint64_t *) input; - input += sizeof(uint64_t); - - // account data - params->ka[i].data_len = *(uint64_t *) input; - input += sizeof(uint64_t); - params->ka[i].data = (uint8_t *) input; - input += params->ka[i].data_len; - - // owner - params->ka[i].owner = (SolPubkey *) input; - input += sizeof(SolPubkey); - - // executable? - params->ka[i].executable = *(uint8_t *) input; - input += sizeof(uint8_t); - - // rent epoch - params->ka[i].rent_epoch = *(uint64_t *) input; - input += sizeof(uint64_t); - } else { - params->ka[i].is_signer = params->ka[dup_info].is_signer; - params->ka[i].key = params->ka[dup_info].key; - params->ka[i].lamports = params->ka[dup_info].lamports; - params->ka[i].data_len = params->ka[dup_info].data_len; - params->ka[i].data = params->ka[dup_info].data; - params->ka[i].owner = params->ka[dup_info].owner; - params->ka[i].executable = params->ka[dup_info].executable; - params->ka[i].rent_epoch = params->ka[dup_info].rent_epoch; - } - } - - params->data_len = *(uint64_t *) input; - input += sizeof(uint64_t); - params->data = input; - input += params->data_len; - - params->program_id = (SolPubkey *) input; - input += sizeof(SolPubkey); - - return true; -} - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/entrypoint.h b/sdk/bpf/c/inc/sol/entrypoint.h deleted file mode 100644 index d3ab21a953912f..00000000000000 --- a/sdk/bpf/c/inc/sol/entrypoint.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once -/** - * @brief Solana program entrypoint - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Keyed Account - */ -typedef struct { - SolPubkey *key; /** Public key of the account */ - uint64_t *lamports; /** Number of lamports owned by this account */ - uint64_t data_len; /** Length of data in bytes */ - uint8_t *data; /** On-chain data within this account */ - SolPubkey *owner; /** Program that owns this account */ - uint64_t rent_epoch; /** The epoch at which this account will next owe rent */ - bool is_signer; /** Transaction was signed by this account's key? */ - bool is_writable; /** Is the account writable? */ - bool executable; /** This account's data contains a loaded program (and is now read-only) */ -} SolAccountInfo; - -/** - * Structure that the program's entrypoint input data is deserialized into. - */ -typedef struct { - SolAccountInfo* ka; /** Pointer to an array of SolAccountInfo, must already - point to an array of SolAccountInfos */ - uint64_t ka_num; /** Number of SolAccountInfo entries in `ka` */ - const uint8_t *data; /** pointer to the instruction data */ - uint64_t data_len; /** Length in bytes of the instruction data */ - const SolPubkey *program_id; /** program_id of the currently executing program */ -} SolParameters; - -/** - * Program instruction entrypoint - * - * @param input Buffer of serialized input parameters. Use sol_deserialize() to decode - * @return 0 if the instruction executed successfully - */ -uint64_t entrypoint(const uint8_t *input); - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/alt_bn128.inc b/sdk/bpf/c/inc/sol/inc/alt_bn128.inc deleted file mode 100644 index 8ba4a925021cd2..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/alt_bn128.inc +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once -/** - * @brief Solana bn128 elliptic curve addition, multiplication, and pairing -**/ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Output length for the add operation. - */ -#define ALT_BN128_ADDITION_OUTPUT_LEN 64 - -/** - * Output length for the add operation. - */ -#define ALT_BN128_MULTIPLICATION_OUTPUT_LEN 64 - -/** - * Output length for pairing operation. - */ -#define ALT_BN128_PAIRING_OUTPUT_LEN 32 - -/** - * Add operation. - */ -#define ALT_BN128_ADD 0 - -/** - * Subtraction operation. - */ -#define ALT_BN128_SUB 1 - -/** - * Multiplication operation. - */ -#define ALT_BN128_MUL 2 - -/** - * Pairing operation. - */ -#define ALT_BN128_PAIRING 3 - -/** - * Addition on elliptic curves alt_bn128 - * - * @param group_op ... - * @param input ... - * @param input_size ... - * @param result 64 byte array to hold the result. ... - * @return 0 if executed successfully - */ -@SYSCALL uint64_t sol_alt_bn128_group_op( - const uint64_t group_op, - const uint8_t *input, - const uint64_t input_size, - uint8_t *result -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/assert.inc b/sdk/bpf/c/inc/sol/inc/assert.inc deleted file mode 100644 index fa523115e2f73a..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/assert.inc +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -/** - * @brief Solana assert and panic utilities - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Panics - * - * Prints the line number where the panic occurred and then causes - * the BPF VM to immediately halt execution. No accounts' data are updated - */ -@SYSCALL void sol_panic_(const char *, uint64_t, uint64_t, uint64_t); -#define sol_panic() sol_panic_(__FILE__, sizeof(__FILE__), __LINE__, 0) - -/** - * Asserts - */ -#define sol_assert(expr) \ -if (!(expr)) { \ - sol_panic(); \ -} - -#ifdef SOL_TEST -/** - * Stub functions when building tests - */ -#include -#include - -void sol_panic_(const char *file, uint64_t len, uint64_t line, uint64_t column) { - printf("Panic in %s at %d:%d\n", file, line, column); - abort(); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/big_mod_exp.inc b/sdk/bpf/c/inc/sol/inc/big_mod_exp.inc deleted file mode 100644 index ce5c6656296d3f..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/big_mod_exp.inc +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -/** - * @brief Solana big_mod_exp system call -**/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Big integer modular exponentiation - * - * @param bytes Pointer to BigModExpParam struct - * @param result 32 byte array to hold the result - * @return 0 if executed successfully - */ -@SYSCALL uint64_t sol_big_mod_exp(const uint8_t *, uint8_t *); - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/blake3.inc b/sdk/bpf/c/inc/sol/inc/blake3.inc deleted file mode 100644 index b2cfd7b3362a46..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/blake3.inc +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -/** - * @brief Solana Blake3 system call - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Length of a Blake3 hash result - */ -#define BLAKE3_RESULT_LENGTH 32 - -/** - * Blake3 - * - * @param bytes Array of byte arrays - * @param bytes_len Number of byte arrays - * @param result 32 byte array to hold the result - */ -@SYSCALL uint64_t sol_blake3(const SolBytes *, int, const uint8_t *); - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/cpi.inc b/sdk/bpf/c/inc/sol/inc/cpi.inc deleted file mode 100644 index 41ce4fb01a691b..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/cpi.inc +++ /dev/null @@ -1,117 +0,0 @@ -#pragma once -/** - * @brief Solana Cross-Program Invocation - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Maximum CPI instruction data size. 10 KiB was chosen to ensure that CPI - * instructions are not more limited than transaction instructions if the size - * of transactions is doubled in the future. - */ -static const uint64_t MAX_CPI_INSTRUCTION_DATA_LEN = 10240; - -/** - * Maximum CPI instruction accounts. 255 was chosen to ensure that instruction - * accounts are always within the maximum instruction account limit for BPF - * program instructions. - */ -static const uint8_t MAX_CPI_INSTRUCTION_ACCOUNTS = 255; - -/** - * Maximum number of account info structs that can be used in a single CPI - * invocation. A limit on account info structs is effectively the same as - * limiting the number of unique accounts. 128 was chosen to match the max - * number of locked accounts per transaction (MAX_TX_ACCOUNT_LOCKS). - */ -static const uint16_t MAX_CPI_ACCOUNT_INFOS = 128; - -/** - * Account Meta - */ -typedef struct { - SolPubkey *pubkey; /** An account's public key */ - bool is_writable; /** True if the `pubkey` can be loaded as a read-write account */ - bool is_signer; /** True if an Instruction requires a Transaction signature matching `pubkey` */ -} SolAccountMeta; - -/** - * Instruction - */ -typedef struct { - SolPubkey *program_id; /** Pubkey of the instruction processor that executes this instruction */ - SolAccountMeta *accounts; /** Metadata for what accounts should be passed to the instruction processor */ - uint64_t account_len; /** Number of SolAccountMetas */ - uint8_t *data; /** Opaque data passed to the instruction processor */ - uint64_t data_len; /** Length of the data in bytes */ -} SolInstruction; - -/** - * Internal cross-program invocation function - */ -@SYSCALL uint64_t sol_invoke_signed_c( - const SolInstruction *, - const SolAccountInfo *, - int, - const SolSignerSeeds *, - int -); - -/** - * Invoke another program and sign for some of the keys - * - * @param instruction Instruction to process - * @param account_infos Accounts used by instruction - * @param account_infos_len Length of account_infos array - * @param seeds Seed bytes used to sign program accounts - * @param seeds_len Length of the seeds array - */ -static uint64_t sol_invoke_signed( - const SolInstruction *instruction, - const SolAccountInfo *account_infos, - int account_infos_len, - const SolSignerSeeds *signers_seeds, - int signers_seeds_len -) { - return sol_invoke_signed_c( - instruction, - account_infos, - account_infos_len, - signers_seeds, - signers_seeds_len - ); -} -/** - * Invoke another program - * - * @param instruction Instruction to process - * @param account_infos Accounts used by instruction - * @param account_infos_len Length of account_infos array -*/ -static uint64_t sol_invoke( - const SolInstruction *instruction, - const SolAccountInfo *account_infos, - int account_infos_len -) { - const SolSignerSeeds signers_seeds[] = {{}}; - return sol_invoke_signed( - instruction, - account_infos, - account_infos_len, - signers_seeds, - 0 - ); -} - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/keccak.inc b/sdk/bpf/c/inc/sol/inc/keccak.inc deleted file mode 100644 index fc882372c1112d..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/keccak.inc +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -/** - * @brief Solana keccak system call -**/ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Length of a Keccak hash result - */ -#define KECCAK_RESULT_LENGTH 32 - -/** - * Keccak - * - * @param bytes Array of byte arrays - * @param bytes_len Number of byte arrays - * @param result 32 byte array to hold the result - */ -@SYSCALL uint64_t sol_keccak256(const SolBytes *, int, uint8_t *); - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/log.inc b/sdk/bpf/c/inc/sol/inc/log.inc deleted file mode 100644 index c6f7e05da19d61..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/log.inc +++ /dev/null @@ -1,103 +0,0 @@ -#pragma once -/** - * @brief Solana logging utilities - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Prints a string to stdout - */ -@SYSCALL void sol_log_(const char *, uint64_t); -#define sol_log(message) sol_log_(message, sol_strlen(message)) - -/** - * Prints a 64 bit values represented in hexadecimal to stdout - */ -@SYSCALL void sol_log_64_(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); -#define sol_log_64 sol_log_64_ - -/** - * Prints the current compute unit consumption to stdout - */ -@SYSCALL void sol_log_compute_units_(); -#define sol_log_compute_units() sol_log_compute_units_() - -/** - * Prints the hexadecimal representation of an array - * - * @param array The array to print - */ -static void sol_log_array(const uint8_t *array, int len) { - for (int j = 0; j < len; j++) { - sol_log_64(0, 0, 0, j, array[j]); - } -} - -/** - * Print the base64 representation of some arrays. - */ -@SYSCALL void sol_log_data(SolBytes *, uint64_t); - -/** - * Prints the program's input parameters - * - * @param params Pointer to a SolParameters structure - */ -static void sol_log_params(const SolParameters *params) { - sol_log("- Program identifier:"); - sol_log_pubkey(params->program_id); - - sol_log("- Number of KeyedAccounts"); - sol_log_64(0, 0, 0, 0, params->ka_num); - for (int i = 0; i < params->ka_num; i++) { - sol_log(" - Is signer"); - sol_log_64(0, 0, 0, 0, params->ka[i].is_signer); - sol_log(" - Is writable"); - sol_log_64(0, 0, 0, 0, params->ka[i].is_writable); - sol_log(" - Key"); - sol_log_pubkey(params->ka[i].key); - sol_log(" - Lamports"); - sol_log_64(0, 0, 0, 0, *params->ka[i].lamports); - sol_log(" - data"); - sol_log_array(params->ka[i].data, params->ka[i].data_len); - sol_log(" - Owner"); - sol_log_pubkey(params->ka[i].owner); - sol_log(" - Executable"); - sol_log_64(0, 0, 0, 0, params->ka[i].executable); - sol_log(" - Rent Epoch"); - sol_log_64(0, 0, 0, 0, params->ka[i].rent_epoch); - } - sol_log("- Instruction data\0"); - sol_log_array(params->data, params->data_len); -} - -#ifdef SOL_TEST -/** - * Stub functions when building tests - */ -#include - -void sol_log_(const char *s, uint64_t len) { - printf("Program log: %s\n", s); -} -void sol_log_64(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) { - printf("Program log: %llu, %llu, %llu, %llu, %llu\n", arg1, arg2, arg3, arg4, arg5); -} - -void sol_log_compute_units_() { - printf("Program consumption: __ units remaining\n"); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/pubkey.inc b/sdk/bpf/c/inc/sol/inc/pubkey.inc deleted file mode 100644 index 5e86e8d39675f3..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/pubkey.inc +++ /dev/null @@ -1,107 +0,0 @@ -#pragma once -/** - * @brief Solana Public key - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Size of Public key in bytes - */ -#define SIZE_PUBKEY 32 - -/** - * Public key - */ -typedef struct { - uint8_t x[SIZE_PUBKEY]; -} SolPubkey; - -/** - * Prints the hexadecimal representation of a public key - * - * @param key The public key to print - */ -@SYSCALL void sol_log_pubkey(const SolPubkey *); - -/** - * Compares two public keys - * - * @param one First public key - * @param two Second public key - * @return true if the same - */ -static bool SolPubkey_same(const SolPubkey *one, const SolPubkey *two) { - for (int i = 0; i < sizeof(*one); i++) { - if (one->x[i] != two->x[i]) { - return false; - } - } - return true; -} - -/** - * Seed used to create a program address or passed to sol_invoke_signed - */ -typedef struct { - const uint8_t *addr; /** Seed bytes */ - uint64_t len; /** Length of the seed bytes */ -} SolSignerSeed; - -/** - * Seeds used by a signer to create a program address or passed to - * sol_invoke_signed - */ -typedef struct { - const SolSignerSeed *addr; /** An array of a signer's seeds */ - uint64_t len; /** Number of seeds */ -} SolSignerSeeds; - -/** - * Create a program address - * - * @param seeds Seed bytes used to sign program accounts - * @param seeds_len Length of the seeds array - * @param program_id Program id of the signer - * @param program_address Program address created, filled on return - */ -@SYSCALL uint64_t sol_create_program_address(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *); - -/** - * Try to find a program address and return corresponding bump seed - * - * @param seeds Seed bytes used to sign program accounts - * @param seeds_len Length of the seeds array - * @param program_id Program id of the signer - * @param program_address Program address created, filled on return - * @param bump_seed Bump seed required to create a valid program address - */ -@SYSCALL uint64_t sol_try_find_program_address(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *, uint8_t *); - -#ifdef SOL_TEST -/** - * Stub functions when building tests - */ -#include - -void sol_log_pubkey( - const SolPubkey *pubkey -) { - printf("Program log: "); - for (int i = 0; i < SIZE_PUBKEY; i++) { - printf("%02 ", pubkey->x[i]); - } - printf("\n"); -} - -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/return_data.inc b/sdk/bpf/c/inc/sol/inc/return_data.inc deleted file mode 100644 index 9c571f489aeceb..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/return_data.inc +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -/** - * @brief Solana return data system calls -**/ - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * Maximum size of return data - */ -#define MAX_RETURN_DATA 1024 - -/** - * Set the return data - * - * @param bytes byte array to set - * @param bytes_len length of byte array. This may not exceed MAX_RETURN_DATA. - */ -@SYSCALL void sol_set_return_data(const uint8_t *, uint64_t); - -/** - * Get the return data - * - * @param bytes byte buffer - * @param bytes_len maximum length of buffer - * @param program_id the program_id which set the return data. Only set if there was some return data (the function returns non-zero). - * @param result length of return data (may exceed bytes_len if the return data is longer) - */ -@SYSCALL uint64_t sol_get_return_data(uint8_t *, uint64_t, SolPubkey *); - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/secp256k1.inc b/sdk/bpf/c/inc/sol/inc/secp256k1.inc deleted file mode 100644 index e42ac5fb94371b..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/secp256k1.inc +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -/** - * @brief Solana secp256k1 system call - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Length of a secp256k1 recover input hash */ -#define SECP256K1_RECOVER_HASH_LENGTH 32 -/** Length of a secp256k1 input signature */ -#define SECP256K1_RECOVER_SIGNATURE_LENGTH 64 -/** Length of a secp256k1 recover result */ -#define SECP256K1_RECOVER_RESULT_LENGTH 64 - -/** The hash provided to a sol_secp256k1_recover is invalid */ -#define SECP256K1_RECOVER_ERROR_INVALID_HASH 1 -/** The recovery_id provided to a sol_secp256k1_recover is invalid */ -#define SECP256K1_RECOVER_ERROR_INVALID_RECOVERY_ID 2 -/** The signature provided to a sol_secp256k1_recover is invalid */ -#define SECP256K1_RECOVER_ERROR_INVALID_SIGNATURE 3 - -/** - * Recover public key from a signed message. - * - * @param hash Hashed message - * @param recovery_id Tag used for public key recovery from signatures. Can be 0 or 1 - * @param signature An ECDSA signature - * @param result 64 byte array to hold the result. A recovered public key - * @return 0 if executed successfully - */ -@SYSCALL uint64_t sol_secp256k1_recover(const uint8_t *, uint64_t, const uint8_t *, uint8_t *); - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/inc/sha.inc b/sdk/bpf/c/inc/sol/inc/sha.inc deleted file mode 100644 index 8acc35cc687868..00000000000000 --- a/sdk/bpf/c/inc/sol/inc/sha.inc +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -/** - * @brief Solana sha system call - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Length of a sha256 hash result - */ -#define SHA256_RESULT_LENGTH 32 - -/** - * Sha256 - * - * @param bytes Array of byte arrays - * @param bytes_len Number of byte arrays - * @param result 32 byte array to hold the result - */ -@SYSCALL uint64_t sol_sha256(const SolBytes *, int, uint8_t *); - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/keccak.h b/sdk/bpf/c/inc/sol/keccak.h deleted file mode 100644 index 213eb4cae18ba6..00000000000000 --- a/sdk/bpf/c/inc/sol/keccak.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -/** - * @brief Solana keccak system call -**/ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Length of a Keccak hash result - */ -#define KECCAK_RESULT_LENGTH 32 - -/** - * Keccak - * - * @param bytes Array of byte arrays - * @param bytes_len Number of byte arrays - * @param result 32 byte array to hold the result - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/keccak.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_keccak256(const SolBytes *, int, uint8_t *); -#else -typedef uint64_t(*sol_keccak256_pointer_type)(const SolBytes *, int, uint8_t *); -static uint64_t sol_keccak256(const SolBytes * arg1, int arg2, uint8_t * arg3) { - sol_keccak256_pointer_type sol_keccak256_pointer = (sol_keccak256_pointer_type) 3615046331; - return sol_keccak256_pointer(arg1, arg2, arg3); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/log.h b/sdk/bpf/c/inc/sol/log.h deleted file mode 100644 index 6dd594e14b4521..00000000000000 --- a/sdk/bpf/c/inc/sol/log.h +++ /dev/null @@ -1,139 +0,0 @@ -#pragma once -/** - * @brief Solana logging utilities - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Prints a string to stdout - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/log.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -void sol_log_(const char *, uint64_t); -#else -typedef void(*sol_log__pointer_type)(const char *, uint64_t); -static void sol_log_(const char * arg1, uint64_t arg2) { - sol_log__pointer_type sol_log__pointer = (sol_log__pointer_type) 544561597; - sol_log__pointer(arg1, arg2); -} -#endif -#define sol_log(message) sol_log_(message, sol_strlen(message)) - -/** - * Prints a 64 bit values represented in hexadecimal to stdout - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/log.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -void sol_log_64_(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); -#else -typedef void(*sol_log_64__pointer_type)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); -static void sol_log_64_(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) { - sol_log_64__pointer_type sol_log_64__pointer = (sol_log_64__pointer_type) 1546269048; - sol_log_64__pointer(arg1, arg2, arg3, arg4, arg5); -} -#endif -#define sol_log_64 sol_log_64_ - -/** - * Prints the current compute unit consumption to stdout - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/log.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -void sol_log_compute_units_(); -#else -typedef void(*sol_log_compute_units__pointer_type)(); -static void sol_log_compute_units_() { - sol_log_compute_units__pointer_type sol_log_compute_units__pointer = (sol_log_compute_units__pointer_type) 1387942038; - sol_log_compute_units__pointer(); -} -#endif -#define sol_log_compute_units() sol_log_compute_units_() - -/** - * Prints the hexadecimal representation of an array - * - * @param array The array to print - */ -static void sol_log_array(const uint8_t *array, int len) { - for (int j = 0; j < len; j++) { - sol_log_64(0, 0, 0, j, array[j]); - } -} - -/** - * Print the base64 representation of some arrays. - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/log.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -void sol_log_data(SolBytes *, uint64_t); -#else -typedef void(*sol_log_data_pointer_type)(SolBytes *, uint64_t); -static void sol_log_data(SolBytes * arg1, uint64_t arg2) { - sol_log_data_pointer_type sol_log_data_pointer = (sol_log_data_pointer_type) 1930933300; - sol_log_data_pointer(arg1, arg2); -} -#endif - -/** - * Prints the program's input parameters - * - * @param params Pointer to a SolParameters structure - */ -static void sol_log_params(const SolParameters *params) { - sol_log("- Program identifier:"); - sol_log_pubkey(params->program_id); - - sol_log("- Number of KeyedAccounts"); - sol_log_64(0, 0, 0, 0, params->ka_num); - for (int i = 0; i < params->ka_num; i++) { - sol_log(" - Is signer"); - sol_log_64(0, 0, 0, 0, params->ka[i].is_signer); - sol_log(" - Is writable"); - sol_log_64(0, 0, 0, 0, params->ka[i].is_writable); - sol_log(" - Key"); - sol_log_pubkey(params->ka[i].key); - sol_log(" - Lamports"); - sol_log_64(0, 0, 0, 0, *params->ka[i].lamports); - sol_log(" - data"); - sol_log_array(params->ka[i].data, params->ka[i].data_len); - sol_log(" - Owner"); - sol_log_pubkey(params->ka[i].owner); - sol_log(" - Executable"); - sol_log_64(0, 0, 0, 0, params->ka[i].executable); - sol_log(" - Rent Epoch"); - sol_log_64(0, 0, 0, 0, params->ka[i].rent_epoch); - } - sol_log("- Instruction data\0"); - sol_log_array(params->data, params->data_len); -} - -#ifdef SOL_TEST -/** - * Stub functions when building tests - */ -#include - -void sol_log_(const char *s, uint64_t len) { - printf("Program log: %s\n", s); -} -void sol_log_64(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) { - printf("Program log: %llu, %llu, %llu, %llu, %llu\n", arg1, arg2, arg3, arg4, arg5); -} - -void sol_log_compute_units_() { - printf("Program consumption: __ units remaining\n"); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/pubkey.h b/sdk/bpf/c/inc/sol/pubkey.h deleted file mode 100644 index a05ae210d58785..00000000000000 --- a/sdk/bpf/c/inc/sol/pubkey.h +++ /dev/null @@ -1,134 +0,0 @@ -#pragma once -/** - * @brief Solana Public key - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Size of Public key in bytes - */ -#define SIZE_PUBKEY 32 - -/** - * Public key - */ -typedef struct { - uint8_t x[SIZE_PUBKEY]; -} SolPubkey; - -/** - * Prints the hexadecimal representation of a public key - * - * @param key The public key to print - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/pubkey.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -void sol_log_pubkey(const SolPubkey *); -#else -typedef void(*sol_log_pubkey_pointer_type)(const SolPubkey *); -static void sol_log_pubkey(const SolPubkey * arg1) { - sol_log_pubkey_pointer_type sol_log_pubkey_pointer = (sol_log_pubkey_pointer_type) 2129692874; - sol_log_pubkey_pointer(arg1); -} -#endif - -/** - * Compares two public keys - * - * @param one First public key - * @param two Second public key - * @return true if the same - */ -static bool SolPubkey_same(const SolPubkey *one, const SolPubkey *two) { - for (int i = 0; i < sizeof(*one); i++) { - if (one->x[i] != two->x[i]) { - return false; - } - } - return true; -} - -/** - * Seed used to create a program address or passed to sol_invoke_signed - */ -typedef struct { - const uint8_t *addr; /** Seed bytes */ - uint64_t len; /** Length of the seed bytes */ -} SolSignerSeed; - -/** - * Seeds used by a signer to create a program address or passed to - * sol_invoke_signed - */ -typedef struct { - const SolSignerSeed *addr; /** An array of a signer's seeds */ - uint64_t len; /** Number of seeds */ -} SolSignerSeeds; - -/** - * Create a program address - * - * @param seeds Seed bytes used to sign program accounts - * @param seeds_len Length of the seeds array - * @param program_id Program id of the signer - * @param program_address Program address created, filled on return - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/pubkey.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_create_program_address(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *); -#else -typedef uint64_t(*sol_create_program_address_pointer_type)(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *); -static uint64_t sol_create_program_address(const SolSignerSeed * arg1, int arg2, const SolPubkey * arg3, SolPubkey * arg4) { - sol_create_program_address_pointer_type sol_create_program_address_pointer = (sol_create_program_address_pointer_type) 2474062396; - return sol_create_program_address_pointer(arg1, arg2, arg3, arg4); -} -#endif - -/** - * Try to find a program address and return corresponding bump seed - * - * @param seeds Seed bytes used to sign program accounts - * @param seeds_len Length of the seeds array - * @param program_id Program id of the signer - * @param program_address Program address created, filled on return - * @param bump_seed Bump seed required to create a valid program address - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/pubkey.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_try_find_program_address(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *, uint8_t *); -#else -typedef uint64_t(*sol_try_find_program_address_pointer_type)(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *, uint8_t *); -static uint64_t sol_try_find_program_address(const SolSignerSeed * arg1, int arg2, const SolPubkey * arg3, SolPubkey * arg4, uint8_t * arg5) { - sol_try_find_program_address_pointer_type sol_try_find_program_address_pointer = (sol_try_find_program_address_pointer_type) 1213221432; - return sol_try_find_program_address_pointer(arg1, arg2, arg3, arg4, arg5); -} -#endif - -#ifdef SOL_TEST -/** - * Stub functions when building tests - */ -#include - -void sol_log_pubkey( - const SolPubkey *pubkey -) { - printf("Program log: "); - for (int i = 0; i < SIZE_PUBKEY; i++) { - printf("%02 ", pubkey->x[i]); - } - printf("\n"); -} - -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/return_data.h b/sdk/bpf/c/inc/sol/return_data.h deleted file mode 100644 index 6afb13513a4b3d..00000000000000 --- a/sdk/bpf/c/inc/sol/return_data.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once -/** - * @brief Solana return data system calls -**/ - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * Maximum size of return data - */ -#define MAX_RETURN_DATA 1024 - -/** - * Set the return data - * - * @param bytes byte array to set - * @param bytes_len length of byte array. This may not exceed MAX_RETURN_DATA. - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/return_data.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -void sol_set_return_data(const uint8_t *, uint64_t); -#else -typedef void(*sol_set_return_data_pointer_type)(const uint8_t *, uint64_t); -static void sol_set_return_data(const uint8_t * arg1, uint64_t arg2) { - sol_set_return_data_pointer_type sol_set_return_data_pointer = (sol_set_return_data_pointer_type) 2720453611; - sol_set_return_data_pointer(arg1, arg2); -} -#endif - -/** - * Get the return data - * - * @param bytes byte buffer - * @param bytes_len maximum length of buffer - * @param program_id the program_id which set the return data. Only set if there was some return data (the function returns non-zero). - * @param result length of return data (may exceed bytes_len if the return data is longer) - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/return_data.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_get_return_data(uint8_t *, uint64_t, SolPubkey *); -#else -typedef uint64_t(*sol_get_return_data_pointer_type)(uint8_t *, uint64_t, SolPubkey *); -static uint64_t sol_get_return_data(uint8_t * arg1, uint64_t arg2, SolPubkey * arg3) { - sol_get_return_data_pointer_type sol_get_return_data_pointer = (sol_get_return_data_pointer_type) 1562527204; - return sol_get_return_data_pointer(arg1, arg2, arg3); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/secp256k1.h b/sdk/bpf/c/inc/sol/secp256k1.h deleted file mode 100644 index f973defe0e3f78..00000000000000 --- a/sdk/bpf/c/inc/sol/secp256k1.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once -/** - * @brief Solana secp256k1 system call - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Length of a secp256k1 recover input hash */ -#define SECP256K1_RECOVER_HASH_LENGTH 32 -/** Length of a secp256k1 input signature */ -#define SECP256K1_RECOVER_SIGNATURE_LENGTH 64 -/** Length of a secp256k1 recover result */ -#define SECP256K1_RECOVER_RESULT_LENGTH 64 - -/** The hash provided to a sol_secp256k1_recover is invalid */ -#define SECP256K1_RECOVER_ERROR_INVALID_HASH 1 -/** The recovery_id provided to a sol_secp256k1_recover is invalid */ -#define SECP256K1_RECOVER_ERROR_INVALID_RECOVERY_ID 2 -/** The signature provided to a sol_secp256k1_recover is invalid */ -#define SECP256K1_RECOVER_ERROR_INVALID_SIGNATURE 3 - -/** - * Recover public key from a signed message. - * - * @param hash Hashed message - * @param recovery_id Tag used for public key recovery from signatures. Can be 0 or 1 - * @param signature An ECDSA signature - * @param result 64 byte array to hold the result. A recovered public key - * @return 0 if executed successfully - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/secp256k1.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_secp256k1_recover(const uint8_t *, uint64_t, const uint8_t *, uint8_t *); -#else -typedef uint64_t(*sol_secp256k1_recover_pointer_type)(const uint8_t *, uint64_t, const uint8_t *, uint8_t *); -static uint64_t sol_secp256k1_recover(const uint8_t * arg1, uint64_t arg2, const uint8_t * arg3, uint8_t * arg4) { - sol_secp256k1_recover_pointer_type sol_secp256k1_recover_pointer = (sol_secp256k1_recover_pointer_type) 400819024; - return sol_secp256k1_recover_pointer(arg1, arg2, arg3, arg4); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/sha.h b/sdk/bpf/c/inc/sol/sha.h deleted file mode 100644 index ad776e8e914713..00000000000000 --- a/sdk/bpf/c/inc/sol/sha.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -/** - * @brief Solana sha system call - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Length of a sha256 hash result - */ -#define SHA256_RESULT_LENGTH 32 - -/** - * Sha256 - * - * @param bytes Array of byte arrays - * @param bytes_len Number of byte arrays - * @param result 32 byte array to hold the result - */ -/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/sol/inc/sha.inc AND RUN `cargo run --bin gen-headers` */ -#ifndef SOL_SBFV2 -uint64_t sol_sha256(const SolBytes *, int, uint8_t *); -#else -typedef uint64_t(*sol_sha256_pointer_type)(const SolBytes *, int, uint8_t *); -static uint64_t sol_sha256(const SolBytes * arg1, int arg2, uint8_t * arg3) { - sol_sha256_pointer_type sol_sha256_pointer = (sol_sha256_pointer_type) 301243782; - return sol_sha256_pointer(arg1, arg2, arg3); -} -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/string.h b/sdk/bpf/c/inc/sol/string.h deleted file mode 100644 index 18de272c9bcbb6..00000000000000 --- a/sdk/bpf/c/inc/sol/string.h +++ /dev/null @@ -1,116 +0,0 @@ -#pragma once -/** - * @brief Solana string and memory system calls and utilities - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Copies memory - */ -static void *sol_memcpy(void *dst, const void *src, int len) { - for (int i = 0; i < len; i++) { - *((uint8_t *)dst + i) = *((const uint8_t *)src + i); - } - return dst; -} - -/** - * Compares memory - */ -static int sol_memcmp(const void *s1, const void *s2, int n) { - for (int i = 0; i < n; i++) { - uint8_t diff = *((uint8_t *)s1 + i) - *((const uint8_t *)s2 + i); - if (diff) { - return diff; - } - } - return 0; -} - -/** - * Fill a byte string with a byte value - */ -static void *sol_memset(void *b, int c, size_t len) { - uint8_t *a = (uint8_t *) b; - while (len > 0) { - *a = c; - a++; - len--; - } - return b; -} - -/** - * Find length of string - */ -static size_t sol_strlen(const char *s) { - size_t len = 0; - while (*s) { - len++; - s++; - } - return len; -} - -/** - * Alloc zero-initialized memory - */ -static void *sol_calloc(size_t nitems, size_t size) { - // Bump allocator - uint64_t* pos_ptr = (uint64_t*)HEAP_START_ADDRESS; - - uint64_t pos = *pos_ptr; - if (pos == 0) { - /** First time, set starting position */ - pos = HEAP_START_ADDRESS + HEAP_LENGTH; - } - - uint64_t bytes = (uint64_t)(nitems * size); - if (size == 0 || - !(nitems == 0 || size == 0) && - !(nitems == bytes / size)) { - /** Overflow */ - return NULL; - } - if (pos < bytes) { - /** Saturated */ - pos = 0; - } else { - pos -= bytes; - } - - uint64_t align = size; - align--; - align |= align >> 1; - align |= align >> 2; - align |= align >> 4; - align |= align >> 8; - align |= align >> 16; - align |= align >> 32; - align++; - pos &= ~(align - 1); - if (pos < HEAP_START_ADDRESS + sizeof(uint8_t*)) { - return NULL; - } - *pos_ptr = pos; - return (void*)pos; -} - -/** - * Deallocates the memory previously allocated by sol_calloc - */ -static void sol_free(void *ptr) { - // I'm a bump allocator, I don't free -} - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/sol/types.h b/sdk/bpf/c/inc/sol/types.h deleted file mode 100644 index ea565f1f940c70..00000000000000 --- a/sdk/bpf/c/inc/sol/types.h +++ /dev/null @@ -1,141 +0,0 @@ -#pragma once -/** - * @brief Solana types for BPF programs - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Pick up static_assert if C11 or greater - * - * Inlined here until is available - */ -#if (defined _ISOC11_SOURCE || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) && !defined (__cplusplus) -#undef static_assert -#define static_assert _Static_assert -#endif - -/** - * Numeric types - */ -#ifndef __LP64__ -#error LP64 data model required -#endif - -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long int int64_t; -typedef unsigned long int uint64_t; -typedef int64_t ssize_t; -typedef uint64_t size_t; - -#if defined (__cplusplus) || defined(static_assert) -static_assert(sizeof(int8_t) == 1); -static_assert(sizeof(uint8_t) == 1); -static_assert(sizeof(int16_t) == 2); -static_assert(sizeof(uint16_t) == 2); -static_assert(sizeof(int32_t) == 4); -static_assert(sizeof(uint32_t) == 4); -static_assert(sizeof(int64_t) == 8); -static_assert(sizeof(uint64_t) == 8); -#endif - -/** - * Minimum of signed integral types - */ -#define INT8_MIN (-128) -#define INT16_MIN (-32767-1) -#define INT32_MIN (-2147483647-1) -#define INT64_MIN (-9223372036854775807L-1) - -/** - * Maximum of signed integral types - */ -#define INT8_MAX (127) -#define INT16_MAX (32767) -#define INT32_MAX (2147483647) -#define INT64_MAX (9223372036854775807L) - -/** - * Maximum of unsigned integral types - */ -#define UINT8_MAX (255) -#define UINT16_MAX (65535) -#define UINT32_MAX (4294967295U) -#define UINT64_MAX (18446744073709551615UL) - -/** - * NULL - */ -#define NULL 0 - -/** Indicates the instruction was processed successfully */ -#define SUCCESS 0 - -/** - * Builtin program status values occupy the upper 32 bits of the program return - * value. Programs may define their own error values but they must be confined - * to the lower 32 bits. - */ -#define TO_BUILTIN(error) ((uint64_t)(error) << 32) - -/** Note: Not applicable to program written in C */ -#define ERROR_CUSTOM_ZERO TO_BUILTIN(1) -/** The arguments provided to a program instruction where invalid */ -#define ERROR_INVALID_ARGUMENT TO_BUILTIN(2) -/** An instruction's data contents was invalid */ -#define ERROR_INVALID_INSTRUCTION_DATA TO_BUILTIN(3) -/** An account's data contents was invalid */ -#define ERROR_INVALID_ACCOUNT_DATA TO_BUILTIN(4) -/** An account's data was too small */ -#define ERROR_ACCOUNT_DATA_TOO_SMALL TO_BUILTIN(5) -/** An account's balance was too small to complete the instruction */ -#define ERROR_INSUFFICIENT_FUNDS TO_BUILTIN(6) -/** The account did not have the expected program id */ -#define ERROR_INCORRECT_PROGRAM_ID TO_BUILTIN(7) -/** A signature was required but not found */ -#define ERROR_MISSING_REQUIRED_SIGNATURES TO_BUILTIN(8) -/** An initialize instruction was sent to an account that has already been initialized */ -#define ERROR_ACCOUNT_ALREADY_INITIALIZED TO_BUILTIN(9) -/** An attempt to operate on an account that hasn't been initialized */ -#define ERROR_UNINITIALIZED_ACCOUNT TO_BUILTIN(10) -/** The instruction expected additional account keys */ -#define ERROR_NOT_ENOUGH_ACCOUNT_KEYS TO_BUILTIN(11) -/** Note: Not applicable to program written in C */ -#define ERROR_ACCOUNT_BORROW_FAILED TO_BUILTIN(12) -/** The length of the seed is too long for address generation */ -#define MAX_SEED_LENGTH_EXCEEDED TO_BUILTIN(13) -/** Provided seeds do not result in a valid address */ -#define INVALID_SEEDS TO_BUILTIN(14) - -/** - * Boolean type - */ -#ifndef __cplusplus -#include -#endif - -/** - * Computes the number of elements in an array - */ -#define SOL_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -/** - * Byte array pointer and string - */ -typedef struct { - const uint8_t *addr; /** bytes */ - uint64_t len; /** number of bytes*/ -} SolBytes; - -#ifdef __cplusplus -} -#endif - -/**@}*/ diff --git a/sdk/bpf/c/inc/solana_sdk.h b/sdk/bpf/c/inc/solana_sdk.h deleted file mode 100644 index 98476758fd432b..00000000000000 --- a/sdk/bpf/c/inc/solana_sdk.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -/** - * @brief Solana C-based BPF program types and utility functions - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/**@}*/ diff --git a/sdk/bpf/c/inc/stdio.h b/sdk/bpf/c/inc/stdio.h deleted file mode 100644 index cd3fda27071dd0..00000000000000 --- a/sdk/bpf/c/inc/stdio.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -typedef void *FILE; - -int printf(const char * restrictformat, ... ); diff --git a/sdk/bpf/c/inc/stdlib.h b/sdk/bpf/c/inc/stdlib.h deleted file mode 100644 index 5d2570c5fed5d7..00000000000000 --- a/sdk/bpf/c/inc/stdlib.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -#include diff --git a/sdk/bpf/c/inc/string.h b/sdk/bpf/c/inc/string.h deleted file mode 100644 index 17cc5489c98fa4..00000000000000 --- a/sdk/bpf/c/inc/string.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -#include - -#define memcpy sol_memcpy -#define memset sol_memset -#define strlen sol_strlen - diff --git a/sdk/bpf/c/inc/sys/param.h b/sdk/bpf/c/inc/sys/param.h deleted file mode 100644 index 6f70f09beec221..00000000000000 --- a/sdk/bpf/c/inc/sys/param.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/sdk/bpf/c/inc/wchar.h b/sdk/bpf/c/inc/wchar.h deleted file mode 100644 index 6f70f09beec221..00000000000000 --- a/sdk/bpf/c/inc/wchar.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/sdk/bpf/env.sh b/sdk/bpf/env.sh deleted file mode 100644 index 3bdf0555f877a6..00000000000000 --- a/sdk/bpf/env.sh +++ /dev/null @@ -1,16 +0,0 @@ -# -# Configures the BPF SDK environment -# - -if [ -z "$bpf_sdk" ]; then - bpf_sdk=. -fi - -# Ensure the sdk is installed -"$bpf_sdk"/scripts/install.sh - -# Use the SDK's version of llvm to build the compiler-builtins for BPF -export CC="$bpf_sdk/dependencies/bpf-tools/llvm/bin/clang" -export AR="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-ar" -export OBJDUMP="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-objdump" -export OBJCOPY="$bpf_sdk/dependencies/bpf-tools/llvm/bin/llvm-objcopy" diff --git a/sdk/bpf/scripts/dump.sh b/sdk/bpf/scripts/dump.sh deleted file mode 100755 index 98686c4f14847f..00000000000000 --- a/sdk/bpf/scripts/dump.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -bpf_sdk=$(cd "$(dirname "$0")/.." && pwd) -# shellcheck source=sdk/bpf/env.sh -source "$bpf_sdk"/env.sh - -so=$1 -dump=$2 -if [[ -z $so ]] || [[ -z $dump ]]; then - echo "Usage: $0 bpf-program.so dump.txt" >&2 - exit 1 -fi - -if [[ ! -r $so ]]; then - echo "Error: File not found or readable: $so" >&2 - exit 1 -fi - -if ! command -v rustfilt > /dev/null; then - echo "Error: rustfilt not found. It can be installed by running: cargo install rustfilt" >&2 - exit 1 -fi - -set -e -out_dir=$(dirname "$dump") -if [[ ! -d $out_dir ]]; then - mkdir -p "$out_dir" -fi -dump_mangled=$dump.mangled - -( - set -ex - ls -la "$so" > "$dump_mangled" - "$bpf_sdk"/dependencies/bpf-tools/llvm/bin/llvm-readelf -aW "$so" >>"$dump_mangled" - "$OBJDUMP" --print-imm-hex --source --disassemble "$so" >> "$dump_mangled" - sed s/://g < "$dump_mangled" | rustfilt > "$dump" -) -rm -f "$dump_mangled" - -if [[ ! -f "$dump" ]]; then - echo "Error: Failed to create $dump" >&2 - exit 1 -fi - -echo >&2 -echo "Wrote $dump" >&2 diff --git a/sdk/bpf/scripts/install.sh b/sdk/bpf/scripts/install.sh deleted file mode 100755 index b7b59362c07a38..00000000000000 --- a/sdk/bpf/scripts/install.sh +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env bash - -mkdir -p "$(dirname "$0")"/../dependencies -cd "$(dirname "$0")"/../dependencies - -unameOut="$(uname -s)" -case "${unameOut}" in - Linux*) - criterion_suffix= - machine=linux;; - Darwin*) - criterion_suffix= - machine=osx;; - MINGW*) - criterion_suffix=-mingw - machine=windows;; - *) - criterion_suffix= - machine=linux -esac -unameOut="$(uname -m)" -case "${unameOut}" in - arm64*) - arch=aarch64;; - *) - arch=x86_64 -esac - -download() { - declare url="$1/$2/$3" - declare filename=$3 - declare wget_args=( - "$url" -O "$filename" - "--progress=dot:giga" - "--retry-connrefused" - "--read-timeout=30" - ) - declare curl_args=( - -L "$url" -o "$filename" - ) - if hash wget 2>/dev/null; then - wget_or_curl="wget ${wget_args[*]}" - elif hash curl 2>/dev/null; then - wget_or_curl="curl ${curl_args[*]}" - else - echo "Error: Neither curl nor wget were found" >&2 - return 1 - fi - - set -x - if $wget_or_curl; then - tar --strip-components 1 -jxf "$filename" || return 1 - { set +x; } 2>/dev/null - rm -rf "$filename" - return 0 - fi - return 1 -} - -get() { - declare version=$1 - declare dirname=$2 - declare job=$3 - declare cache_root=~/.cache/solana - declare cache_dirname="$cache_root/$version/$dirname" - declare cache_partial_dirname="$cache_dirname"_partial - - if [[ -r $cache_dirname ]]; then - ln -sf "$cache_dirname" "$dirname" || return 1 - return 0 - fi - - rm -rf "$cache_partial_dirname" || return 1 - mkdir -p "$cache_partial_dirname" || return 1 - pushd "$cache_partial_dirname" - - if $job; then - popd - mv "$cache_partial_dirname" "$cache_dirname" || return 1 - ln -sf "$cache_dirname" "$dirname" || return 1 - return 0 - fi - popd - return 1 -} - -# Install Criterion -if [[ $machine == "linux" ]]; then - version=v2.3.3 -else - version=v2.3.2 -fi -if [[ ! -e criterion-$version.md || ! -e criterion ]]; then - ( - set -e - rm -rf criterion* - job="download \ - https://github.com/Snaipe/Criterion/releases/download \ - $version \ - criterion-$version-$machine$criterion_suffix-x86_64.tar.bz2 \ - criterion" - get $version criterion "$job" - ) - exitcode=$? - if [[ $exitcode -ne 0 ]]; then - exit 1 - fi - touch criterion-$version.md -fi - -# Install Rust-BPF -version=v1.41 -if [[ ! -e bpf-tools-$version.md || ! -e bpf-tools ]]; then - ( - set -e - rm -rf bpf-tools* - rm -rf xargo - job="download \ - https://github.com/anza-xyz/platform-tools/releases/download \ - $version \ - platform-tools-${machine}-${arch}.tar.bz2 \ - bpf-tools" - get $version bpf-tools "$job" - ) - exitcode=$? - if [[ $exitcode -ne 0 ]]; then - exit 1 - fi - touch bpf-tools-$version.md - set -ex - ./bpf-tools/rust/bin/rustc --version - ./bpf-tools/rust/bin/rustc --print sysroot - set +e - rustup toolchain uninstall bpf - set -e - rustup toolchain link bpf bpf-tools/rust -fi - -exit 0 diff --git a/sdk/bpf/scripts/objcopy.sh b/sdk/bpf/scripts/objcopy.sh deleted file mode 100755 index c818991ccffd3b..00000000000000 --- a/sdk/bpf/scripts/objcopy.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -bpf_sdk=$(cd "$(dirname "$0")/.." && pwd) -# shellcheck source=sdk/bpf/env.sh -source "$bpf_sdk"/env.sh -exec "$bpf_sdk"/dependencies/bpf-tools/llvm/bin/llvm-objcopy "$@" diff --git a/sdk/bpf/scripts/package.sh b/sdk/bpf/scripts/package.sh deleted file mode 100755 index 040ac1cb1efef6..00000000000000 --- a/sdk/bpf/scripts/package.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -ex - -cd "$(dirname "$0")"/../../.. - -echo --- Creating bpf-sdk tarball - -rm -rf bpf-sdk.tar.bz2 bpf-sdk/ -mkdir bpf-sdk/ -cp LICENSE bpf-sdk/ - -( - ci/crate-version.sh sdk/Cargo.toml - git rev-parse HEAD -) > bpf-sdk/version.txt - -cp -a sdk/bpf/* bpf-sdk/ - -tar jvcf bpf-sdk.tar.bz2 bpf-sdk/ diff --git a/sdk/bpf/scripts/strip.sh b/sdk/bpf/scripts/strip.sh deleted file mode 100755 index eafa4fd822057d..00000000000000 --- a/sdk/bpf/scripts/strip.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -so=$1 -if [[ ! -r $so ]]; then - echo "Error: file not found: $so" - exit 1 -fi -so_stripped=$2 -if [[ -z $so_stripped ]]; then - echo "Usage: $0 unstripped.so stripped.so" - exit 1 -fi - -bpf_sdk=$(cd "$(dirname "$0")/.." && pwd) -# shellcheck source=sdk/bpf/env.sh -source "$bpf_sdk"/env.sh - -set -e -out_dir=$(dirname "$so_stripped") -if [[ ! -d $out_dir ]]; then - mkdir -p "$out_dir" -fi -"$bpf_sdk"/dependencies/bpf-tools/llvm/bin/llvm-objcopy --strip-all "$so" "$so_stripped" diff --git a/sdk/cargo-build-bpf/.gitignore b/sdk/cargo-build-bpf/.gitignore deleted file mode 100644 index 03314f77b5aa45..00000000000000 --- a/sdk/cargo-build-bpf/.gitignore +++ /dev/null @@ -1 +0,0 @@ -Cargo.lock diff --git a/sdk/cargo-build-bpf/Cargo.toml b/sdk/cargo-build-bpf/Cargo.toml deleted file mode 100644 index a609ee13c9c3d2..00000000000000 --- a/sdk/cargo-build-bpf/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "solana-cargo-build-bpf" -description = "Compile a local package and all of its dependencies using the Solana SBF SDK" -publish = false -version = { workspace = true } -authors = { workspace = true } -repository = { workspace = true } -homepage = { workspace = true } -license = { workspace = true } -edition = { workspace = true } - -[dependencies] -log = { workspace = true, features = ["std"] } -solana-logger = { workspace = true } - -[features] -program = [] - -[[bin]] -name = "cargo-build-bpf" -path = "src/main.rs" diff --git a/sdk/cargo-build-bpf/src/main.rs b/sdk/cargo-build-bpf/src/main.rs deleted file mode 100644 index 3635901eeceb4d..00000000000000 --- a/sdk/cargo-build-bpf/src/main.rs +++ /dev/null @@ -1,58 +0,0 @@ -use { - log::*, - std::{ - env, - path::PathBuf, - process::{exit, Command, Stdio}, - }, -}; - -fn main() { - solana_logger::setup(); - warn!("cargo-build-bpf is deprecated. Please, use cargo-build-sbf"); - let mut args = env::args() - .map(|x| { - let s = x; - s.replace("--bpf", "--sbf") - }) - .collect::>(); - let program = if let Some(arg0) = args.first() { - let arg0 = arg0.replace("build-bpf", "build-sbf"); - args.remove(0); - PathBuf::from(arg0) - } else { - PathBuf::from("cargo-build-sbf") - }; - // When run as a cargo subcommand, the first program argument is the subcommand name. - // Remove it - if let Some(arg0) = args.first() { - if arg0 == "build-bpf" { - args.remove(0); - } - } - info!("cargo-build-bpf child: {}", program.display()); - for a in &args { - info!(" {}", a); - } - let child = Command::new(&program) - .args(&args) - .stdout(Stdio::piped()) - .spawn() - .unwrap_or_else(|err| { - error!("Failed to execute {}: {}", program.display(), err); - exit(1); - }); - - let output = child.wait_with_output().expect("failed to wait on child"); - info!( - "{}", - output - .stdout - .as_slice() - .iter() - .map(|&c| c as char) - .collect::() - ); - let code = output.status.code().unwrap_or(1); - exit(code); -} diff --git a/sdk/cargo-test-bpf/Cargo.toml b/sdk/cargo-test-bpf/Cargo.toml deleted file mode 100644 index a639225b3a2539..00000000000000 --- a/sdk/cargo-test-bpf/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "solana-cargo-test-bpf" -description = "Execute all unit and integration tests after building with the Solana SBF SDK" -publish = false -version = { workspace = true } -authors = { workspace = true } -repository = { workspace = true } -homepage = { workspace = true } -license = { workspace = true } -edition = { workspace = true } - -[[bin]] -name = "cargo-test-bpf" -path = "src/main.rs" diff --git a/sdk/cargo-test-bpf/src/main.rs b/sdk/cargo-test-bpf/src/main.rs deleted file mode 100644 index 21b8735787de19..00000000000000 --- a/sdk/cargo-test-bpf/src/main.rs +++ /dev/null @@ -1,61 +0,0 @@ -use std::{ - env, - path::PathBuf, - process::{exit, Command, Stdio}, -}; - -fn main() { - println!("Warning: cargo-test-bpf is deprecated. Please, use cargo-test-sbf"); - let mut args = env::args() - .map(|x| { - let s = x; - s.replace("--bpf", "--sbf") - }) - .collect::>(); - if let Ok(cargo_build_bpf) = env::var("CARGO_BUILD_BPF") { - let cargo_build_sbf = cargo_build_bpf.replace("build-bpf", "build-sbf"); - env::set_var("CARGO_BUILD_SBF", cargo_build_sbf); - } - let program = if let Some(arg0) = args.first() { - let cargo_test_sbf = arg0.replace("test-bpf", "test-sbf"); - let cargo_build_sbf = cargo_test_sbf.replace("test-sbf", "build-sbf"); - env::set_var("CARGO_BUILD_SBF", cargo_build_sbf); - args.remove(0); - PathBuf::from(cargo_test_sbf) - } else { - PathBuf::from("cargo-test-sbf") - }; - // When run as a cargo subcommand, the first program argument is the subcommand name. - // Remove it - if let Some(arg0) = args.first() { - if arg0 == "test-bpf" { - args.remove(0); - } - } - print!("cargo-test-bpf child: {}", program.display()); - for a in &args { - print!(" {a}"); - } - println!(); - let child = Command::new(&program) - .args(&args) - .stdout(Stdio::piped()) - .spawn() - .unwrap_or_else(|err| { - eprintln!("Failed to execute {}: {}", program.display(), err); - exit(1); - }); - - let output = child.wait_with_output().expect("failed to wait on child"); - println!( - "{}", - output - .stdout - .as_slice() - .iter() - .map(|&c| c as char) - .collect::() - ); - let code = output.status.code().unwrap_or(1); - exit(code); -}