Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Initial Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
topdefi committed Mar 19, 2024
1 parent 4a916b4 commit 0479299
Show file tree
Hide file tree
Showing 1,463 changed files with 459,188 additions and 0 deletions.
1 change: 1 addition & 0 deletions .buildkite/env/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/secrets_unencrypted.ejson
31 changes: 31 additions & 0 deletions .buildkite/env/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

[ejson](https://github.com/Shopify/ejson) and
[ejson2env](https://github.com/Shopify/ejson2env) are used to manage access
tokens and other secrets required for CI.

#### Setup
```bash
$ sudo gem install ejson ejson2env
```

then obtain the necessary keypair and place it in `/opt/ejson/keys/`.

#### Usage
Run the following command to decrypt the secrets into the environment:
```bash
eval $(ejson2env secrets.ejson)
```

#### Managing secrets.ejson
To decrypt `secrets.ejson` for modification, run:
```bash
$ ejson decrypt secrets.ejson -o secrets_unencrypted.ejson
```

Edit, then run the following to re-encrypt the file **BEFORE COMMITING YOUR
CHANGES**:
```bash
$ ejson encrypt secrets_unencrypted.ejson
$ mv secrets_unencrypted.ejson secrets.ejson
```

7 changes: 7 additions & 0 deletions .buildkite/env/secrets.ejson
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"_public_key": "ae29f4f7ad2fc92de70d470e411c8426d5d48db8817c9e3dae574b122192335f",
"_comment": "These credentials are encrypted and pose no risk",
"environment": {
"CODECOV_TOKEN": "EJ[1:KToenD1Sr3w82lHGxz1n+j3hwNlLk/1pYrjZHlvY6kE=:hN1Q25omtJ+4yYVn+qzIsPLKT3O6J9XN:DMLNLXi/pkWgvwF6gNIcNF222sgsRR9LnwLZYj0P0wGj7q6w8YQnd1Rskj+sRroI/z5pQg==]"
}
}
42 changes: 42 additions & 0 deletions .buildkite/hooks/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CI_BUILD_START=$(date +%s)
export CI_BUILD_START

source ci/env.sh

#
# Kill any running docker containers, which are potentially left over from the
# previous CI job
#
(
containers=$(docker ps -q)
if [[ $(hostname) != metrics-solana-com && -n $containers ]]; then
echo "+++ Killing stale docker containers"
docker ps

# shellcheck disable=SC2086 # Don't want to double quote $containers
docker kill $containers
fi
)

# Processes from previously aborted CI jobs seem to loiter, unclear why as one
# would expect the buildkite-agent to clean up all child processes of the
# aborted CI job.
# But as a workaround for now manually kill some known loiterers. These
# processes will all have the `init` process as their PPID:
(
victims=
for name in bash cargo docker solana; do
victims="$victims $(pgrep -u "$(id -u)" -P 1 -d \ $name)"
done
for victim in $victims; do
echo "Killing pid $victim"
kill -9 "$victim" || true
done
)

# HACK: These are in our docker images, need to be removed from CARGO_HOME
# because we try to cache downloads across builds with CARGO_HOME
# cargo lacks a facility for "system" tooling, always tries CARGO_HOME first
cargo uninstall cargo-audit || true
cargo uninstall svgbob_cli || true
cargo uninstall mdbook || true
42 changes: 42 additions & 0 deletions .buildkite/hooks/post-checkout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CI_BUILD_START=$(date +%s)
export CI_BUILD_START

source ci/env.sh

#
# Kill any running docker containers, which are potentially left over from the
# previous CI job
#
(
containers=$(docker ps -q)
if [[ $(hostname) != metrics-solana-com && -n $containers ]]; then
echo "+++ Killing stale docker containers"
docker ps

# shellcheck disable=SC2086 # Don't want to double quote $containers
docker kill $containers
fi
)

# Processes from previously aborted CI jobs seem to loiter, unclear why as one
# would expect the buildkite-agent to clean up all child processes of the
# aborted CI job.
# But as a workaround for now manually kill some known loiterers. These
# processes will all have the `init` process as their PPID:
(
victims=
for name in bash cargo docker solana; do
victims="$victims $(pgrep -u "$(id -u)" -P 1 -d \ $name)"
done
for victim in $victims; do
echo "Killing pid $victim"
kill -9 "$victim" || true
done
)

# HACK: These are in our docker images, need to be removed from CARGO_HOME
# because we try to cache downloads across builds with CARGO_HOME
# cargo lacks a facility for "system" tooling, always tries CARGO_HOME first
cargo uninstall cargo-audit || true
cargo uninstall svgbob_cli || true
cargo uninstall mdbook || true
49 changes: 49 additions & 0 deletions .buildkite/hooks/post-command
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash -e

#
# Save target/ for the next CI build on this machine
#
if [[ -z $CARGO_TARGET_CACHE ]]; then
echo "+++ CARGO_TARGET_CACHE not defined" # pre-command should have defined it
else
(
set -x
mkdir -p "$CARGO_TARGET_CACHE"
set -x
rsync -a --delete --link-dest="$PWD" target "$CARGO_TARGET_CACHE"
du -hs "$CARGO_TARGET_CACHE"
read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$CARGO_TARGET_CACHE")
echo "--- ${cacheSizeInGB}GB: $CARGO_TARGET_CACHE"
)
fi

#
# Add job_stats data point
#
if [[ -z $CI_BUILD_START ]]; then
echo Error: CI_BUILD_START empty
else
CI_BUILD_DURATION=$(( $(date +%s) - CI_BUILD_START + 1 ))

CI_LABEL=${BUILDKITE_LABEL:-build label missing}

PR=false
if [[ $BUILDKITE_BRANCH =~ pull/* ]]; then
PR=true
fi

SUCCESS=true
if [[ $BUILDKITE_COMMAND_EXIT_STATUS != 0 ]]; then
SUCCESS=false
fi

point_tags="pipeline=$BUILDKITE_PIPELINE_SLUG,job=$CI_LABEL,pr=$PR,success=$SUCCESS"
point_tags="${point_tags// /\\ }" # Escape spaces

point_fields="duration=$CI_BUILD_DURATION"
point_fields="${point_fields// /\\ }" # Escape spaces

point="job_stats,$point_tags $point_fields"

scripts/metrics-write-datapoint.sh "$point" || true
fi
49 changes: 49 additions & 0 deletions .buildkite/hooks/post-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash -e

#
# Save target/ for the next CI build on this machine
#
if [[ -z $CARGO_TARGET_CACHE ]]; then
echo "+++ CARGO_TARGET_CACHE not defined" # pre-command should have defined it
else
(
set -x
mkdir -p "$CARGO_TARGET_CACHE"
set -x
rsync -a --delete --link-dest="$PWD" target "$CARGO_TARGET_CACHE"
du -hs "$CARGO_TARGET_CACHE"
read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$CARGO_TARGET_CACHE")
echo "--- ${cacheSizeInGB}GB: $CARGO_TARGET_CACHE"
)
fi

#
# Add job_stats data point
#
if [[ -z $CI_BUILD_START ]]; then
echo Error: CI_BUILD_START empty
else
CI_BUILD_DURATION=$(( $(date +%s) - CI_BUILD_START + 1 ))

CI_LABEL=${BUILDKITE_LABEL:-build label missing}

PR=false
if [[ $BUILDKITE_BRANCH =~ pull/* ]]; then
PR=true
fi

SUCCESS=true
if [[ $BUILDKITE_COMMAND_EXIT_STATUS != 0 ]]; then
SUCCESS=false
fi

point_tags="pipeline=$BUILDKITE_PIPELINE_SLUG,job=$CI_LABEL,pr=$PR,success=$SUCCESS"
point_tags="${point_tags// /\\ }" # Escape spaces

point_fields="duration=$CI_BUILD_DURATION"
point_fields="${point_fields// /\\ }" # Escape spaces

point="job_stats,$point_tags $point_fields"

scripts/metrics-write-datapoint.sh "$point" || true
fi
43 changes: 43 additions & 0 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -e

eval "$(ejson2env .buildkite/env/secrets.ejson)"

# Ensure the pattern "+++ ..." never occurs when |set -x| is set, as buildkite
# interprets this as the start of a log group.
# Ref: https://buildkite.com/docs/pipelines/managing-log-output
export PS4="++"

#
# Restore target/ from the previous CI build on this machine
#
eval "$(ci/channel-info.sh)"
eval "$(ci/sbf-tools-info.sh)"
export CARGO_TARGET_CACHE=$HOME/cargo-target-cache/"$CHANNEL"-"$BUILDKITE_LABEL"-"$SBF_TOOLS_VERSION"
(
set -x
MAX_CACHE_SIZE=18 # gigabytes

if [[ -d $CARGO_TARGET_CACHE ]]; then
du -hs "$CARGO_TARGET_CACHE"
read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$CARGO_TARGET_CACHE")
echo "--- ${cacheSizeInGB}GB: $CARGO_TARGET_CACHE"
if [[ $cacheSizeInGB -gt $MAX_CACHE_SIZE ]]; then
echo "--- $CARGO_TARGET_CACHE is too large, removing it"
rm -rf "$CARGO_TARGET_CACHE"
fi
else
echo "--- $CARGO_TARGET_CACHE not present"
fi

mkdir -p "$CARGO_TARGET_CACHE"/target
rsync -a --delete --link-dest="$CARGO_TARGET_CACHE" "$CARGO_TARGET_CACHE"/target .

# Don't reuse BPF target build artifacts due to incremental build issues with
# `std:
# "found possibly newer version of crate `std` which `xyz` depends on
rm -rf target/bpfel-unknown-unknown
if [[ $BUILDKITE_LABEL = "stable-perf" ]]; then
rm -rf target/release
fi
)
43 changes: 43 additions & 0 deletions .buildkite/hooks/pre-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -e

eval "$(ejson2env .buildkite/env/secrets.ejson)"

# Ensure the pattern "+++ ..." never occurs when |set -x| is set, as buildkite
# interprets this as the start of a log group.
# Ref: https://buildkite.com/docs/pipelines/managing-log-output
export PS4="++"

#
# Restore target/ from the previous CI build on this machine
#
eval "$(ci/channel-info.sh)"
eval "$(ci/sbf-tools-info.sh)"
export CARGO_TARGET_CACHE=$HOME/cargo-target-cache/"$CHANNEL"-"$BUILDKITE_LABEL"-"$SBF_TOOLS_VERSION"
(
set -x
MAX_CACHE_SIZE=18 # gigabytes

if [[ -d $CARGO_TARGET_CACHE ]]; then
du -hs "$CARGO_TARGET_CACHE"
read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$CARGO_TARGET_CACHE")
echo "--- ${cacheSizeInGB}GB: $CARGO_TARGET_CACHE"
if [[ $cacheSizeInGB -gt $MAX_CACHE_SIZE ]]; then
echo "--- $CARGO_TARGET_CACHE is too large, removing it"
rm -rf "$CARGO_TARGET_CACHE"
fi
else
echo "--- $CARGO_TARGET_CACHE not present"
fi

mkdir -p "$CARGO_TARGET_CACHE"/target
rsync -a --delete --link-dest="$CARGO_TARGET_CACHE" "$CARGO_TARGET_CACHE"/target .

# Don't reuse BPF target build artifacts due to incremental build issues with
# `std:
# "found possibly newer version of crate `std` which `xyz` depends on
rm -rf target/bpfel-unknown-unknown
if [[ $BUILDKITE_LABEL = "stable-perf" ]]; then
rm -rf target/release
fi
)
18 changes: 18 additions & 0 deletions .buildkite/pipeline-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
#
# This script is used to upload the full buildkite pipeline. The steps defined
# in the buildkite UI should simply be:
#
# steps:
# - command: ".buildkite/pipeline-upload.sh"
#

set -e
cd "$(dirname "$0")"/..
source ci/_

_ ci/buildkite-pipeline.sh pipeline.yml
echo +++ pipeline
cat pipeline.yml

_ buildkite-agent pipeline upload pipeline.yml
20 changes: 20 additions & 0 deletions .buildkite/solana-private.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# This script is used to upload the full buildkite pipeline. The steps defined
# in the buildkite UI should simply be:
#
# steps:
# - command: ".buildkite/pipeline-upload.sh"
#

set -e
# NAME=$(buildkite-agent meta-data get name)
cd "$(dirname "$0")"/..
source ci/_
sudo chmod 0777 ci/buildkite-solana-private.sh

_ ci/buildkite-solana-private.sh pipeline.yml
echo +++ pipeline
cat pipeline.yml

_ buildkite-agent pipeline upload pipeline.yml
1 change: 1 addition & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
too-many-arguments-threshold = 9
12 changes: 12 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
coverage:
range: 50..100
round: down
precision: 1
status:
project: off
patch: off

comment:
layout: "diff"
behavior: default
require_changes: no
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
target/*
docs/node_modules/
docs/build/
explorer/node_modules/
programs/bpf/target/
Dockerfile

local-cluster/farf/
core/farf/
cli/farf/
bench-tps/farf/
ledger/farf/
ledger-tools/farf/
sdk/farf/


config
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#### Problem



#### Proposed Solution

Loading

0 comments on commit 0479299

Please sign in to comment.