check rust programs (#4688)
This commit is contained in:
parent
f8523db51d
commit
b430762a23
|
@ -2,7 +2,7 @@ steps:
|
|||
- command: "ci/shellcheck.sh"
|
||||
name: "shellcheck"
|
||||
timeout_in_minutes: 5
|
||||
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_stable_docker_image ci/test-checks.sh"
|
||||
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_nightly_docker_image ci/test-checks.sh"
|
||||
name: "checks"
|
||||
timeout_in_minutes: 15
|
||||
- wait
|
||||
|
|
|
@ -3,6 +3,7 @@ ARG date
|
|||
|
||||
RUN set -x \
|
||||
&& rustup install nightly-$date \
|
||||
&& rustup component add clippy --toolchain=nightly-$date \
|
||||
&& rustup show \
|
||||
&& rustc --version \
|
||||
&& cargo --version \
|
||||
|
|
|
@ -15,12 +15,12 @@ To update the pinned version:
|
|||
1. Run `ci/docker-rust-nightly/build.sh` to rebuild the nightly image locally,
|
||||
or potentially `ci/docker-rust-nightly/build.sh YYYY-MM-DD` if there's a
|
||||
specific YYYY-MM-DD that is desired (default is today's build).
|
||||
1. Update `ci/rust-version.sh` to reflect the new nightly `YYY-MM-DD`
|
||||
1. Run `SOLANA_DOCKER_RUN_NOSETUID=1 ci/docker-run.sh --nopull solanalabs/rust-nightly:YYYY-MM-DD ci/test-coverage.sh`
|
||||
to confirm the new nightly image builds. Fix any issues as needed
|
||||
1. Run `docker login` to enable pushing images to Docker Hub, if you're authorized.
|
||||
1. Run `CI=true ci/docker-rust-nightly/build.sh YYYY-MM-DD` to push the new nightly image to dockerhub.com.
|
||||
1. Modify the `solanalabs/rust-nightly:YYYY-MM-DD` reference in `ci/rust-version.sh` from the previous to
|
||||
new *YYYY-MM-DD* value, send a PR with this change and any codebase adjustments needed.
|
||||
1. Send a PR with the `ci/rust-version.sh` change and any codebase adjustments needed.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
|
|
@ -23,11 +23,13 @@ declare print_free_tree=(
|
|||
'metrics/src'
|
||||
'netutil/src'
|
||||
'runtime/src'
|
||||
'sdk/bpf/rust/rust-utils'
|
||||
'sdk/src'
|
||||
'programs/vote_api/src'
|
||||
'programs/vote_program/src'
|
||||
'programs/bpf/rust'
|
||||
'programs/stake_api/src'
|
||||
'programs/stake_program/src'
|
||||
'programs/vote_api/src'
|
||||
'programs/vote_program/src'
|
||||
)
|
||||
|
||||
if _ git --no-pager grep -n --max-depth=0 "${prints[@]/#/-e }" -- "${print_free_tree[@]}"; then
|
||||
|
|
|
@ -13,11 +13,14 @@
|
|||
# $ source ci/rust-version.sh
|
||||
#
|
||||
|
||||
export rust_stable=1.35.0
|
||||
export rust_stable_docker_image=solanalabs/rust:1.35.0
|
||||
stable_version=1.35.0
|
||||
nightly_version=2019-06-20
|
||||
|
||||
export rust_nightly=nightly-2019-05-01
|
||||
export rust_nightly_docker_image=solanalabs/rust-nightly:2019-05-01
|
||||
export rust_stable="$stable_version"
|
||||
export rust_stable_docker_image=solanalabs/rust:"$stable_version"
|
||||
|
||||
export rust_nightly=nightly-"$nightly_version"
|
||||
export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version"
|
||||
|
||||
[[ -z $1 ]] || (
|
||||
|
||||
|
|
|
@ -5,10 +5,23 @@ cd "$(dirname "$0")/.."
|
|||
|
||||
source ci/_
|
||||
source ci/rust-version.sh stable
|
||||
source ci/rust-version.sh nightly
|
||||
|
||||
export RUST_BACKTRACE=1
|
||||
export RUSTFLAGS="-D warnings"
|
||||
|
||||
(
|
||||
for project in programs/bpf/rust/*/ ; do
|
||||
(
|
||||
cd "$project"
|
||||
_ cargo +"$rust_stable" fmt --all -- --check
|
||||
_ cargo +"$rust_nightly" clippy --all -- --version
|
||||
_ cargo +"$rust_nightly" clippy --all -- --deny=warnings
|
||||
_ cargo +"$rust_stable" audit
|
||||
)
|
||||
done
|
||||
)
|
||||
|
||||
_ cargo +"$rust_stable" fmt --all -- --check
|
||||
_ cargo +"$rust_stable" clippy --all -- --version
|
||||
_ cargo +"$rust_stable" clippy --all -- --deny=warnings
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! @brief Example Rust-based BPF program that test dynamic memory allocation
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
|
@ -52,7 +53,7 @@ pub extern "C" fn entrypoint(_input: *mut u8) -> bool {
|
|||
for i in 0..ITERS {
|
||||
assert_eq!(*ptr.add(i as usize), i as u8);
|
||||
}
|
||||
sol_log_64(0x3, 0, 0, 0, *ptr.add(42) as u64);
|
||||
sol_log_64(0x3, 0, 0, 0, u64::from(*ptr.add(42)));
|
||||
assert_eq!(*ptr.add(42), 42);
|
||||
alloc::alloc::dealloc(ptr, layout);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! @brief Example Rust-based BPF program tests dependent crates
|
||||
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! @brief Example Rust-based BPF program tests loop iteration
|
||||
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! @brief Example Rust-based BPF program tests loop iteration
|
||||
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
mod helper;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! @brief Example Rust-based BPF program that prints out the parameters passed to it
|
||||
|
||||
#![no_std]
|
||||
#![allow(unreachable_code)]
|
||||
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
|
@ -37,7 +38,7 @@ fn process_instruction(
|
|||
{
|
||||
// Test - arch config
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
assert!(false);
|
||||
panic!();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! @brief Example Rust-based BPF program that panics
|
||||
|
||||
#![no_std]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
extern crate solana_sdk_bpf_utils;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ fn process_instruction(
|
|||
let tick_height = LittleEndian::read_u64(k.data);
|
||||
assert_eq!(10u64, tick_height);
|
||||
sol_log("Success");
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
panic!();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ pub struct SolClusterInfo<'a> {
|
|||
macro_rules! entrypoint {
|
||||
($process_instruction:ident) => {
|
||||
#[no_mangle]
|
||||
pub extern "C" fn entrypoint(input: *mut u8) -> bool {
|
||||
pub unsafe extern "C" fn entrypoint(input: *mut u8) -> bool {
|
||||
unsafe {
|
||||
if let Ok((mut ka, info, data)) = $crate::entrypoint::deserialize(input) {
|
||||
// Call use function
|
||||
|
@ -86,9 +86,9 @@ pub unsafe fn deserialize<'a>(
|
|||
return Err(());
|
||||
}
|
||||
|
||||
let mut ka: [Option<SolKeyedAccount>; MAX_ACCOUNTS] =
|
||||
let mut kas: [Option<SolKeyedAccount>; MAX_ACCOUNTS] =
|
||||
[None, None, None, None, None, None, None, None, None, None];
|
||||
for i in 0..num_ka {
|
||||
for ka in kas.iter_mut().take(num_ka) {
|
||||
let is_signer = {
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let is_signer_val = *(input.add(offset) as *const u64);
|
||||
|
@ -121,7 +121,7 @@ pub unsafe fn deserialize<'a>(
|
|||
};
|
||||
offset += SIZE_PUBKEY;
|
||||
|
||||
ka[i] = Some(SolKeyedAccount {
|
||||
*ka = Some(SolKeyedAccount {
|
||||
key,
|
||||
is_signer,
|
||||
lamports,
|
||||
|
@ -149,7 +149,7 @@ pub unsafe fn deserialize<'a>(
|
|||
|
||||
let info = SolClusterInfo { program_id };
|
||||
|
||||
Ok((ka, info, data))
|
||||
Ok((kas, info, data))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#![feature(alloc_error_handler)]
|
||||
#![feature(panic_info_message)]
|
||||
#![feature(compiler_builtins_lib)]
|
||||
#![feature(lang_items)]
|
||||
#[lang = "eh_personality"] extern fn eh_personality() {}
|
||||
|
||||
extern crate compiler_builtins;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! @brief Solana Rust-based BPF program panic handling
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use core::ptr;
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[panic_handler]
|
||||
|
@ -22,7 +23,7 @@ fn panic(info: &PanicInfo) -> ! {
|
|||
);
|
||||
}
|
||||
}
|
||||
None => unsafe { sol_panic_(0 as *const u8, 0, 0) },
|
||||
None => unsafe { sol_panic_(ptr::null(), 0, 0) },
|
||||
}
|
||||
}
|
||||
extern "C" {
|
||||
|
|
Loading…
Reference in New Issue