Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
698 changes: 24 additions & 674 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

118 changes: 42 additions & 76 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 1.2.3) - leave empty for master build'
required: false
type: string
workflow_call:
inputs:
version:
description: 'Release version (e.g., 1.2.3)'
description: 'Release version (e.g., 1.2.3) - leave empty for edge build'
required: false
type: string
release:
Expand All @@ -28,19 +22,13 @@ jobs:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Create docker-binary directory
run: mkdir -p docker-binary

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@v2
with:
key: x86_64-unknown-linux-gnu-docker

Expand All @@ -53,32 +41,30 @@ jobs:
working-directory: crates/cli
env:
RUSTFLAGS: '-C target-cpu=x86-64-v2'
run: |
cargo build --release --target x86_64-unknown-linux-gnu --features jemalloc
run: cargo build --release --target x86_64-unknown-linux-gnu --features jemalloc

- name: Prepare binary for Docker
run: |
mkdir -p docker-binary
cp target/x86_64-unknown-linux-gnu/release/rrelayer_cli docker-binary/rrelayer_cli
chmod +x docker-binary/rrelayer_cli

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
- name: Log into registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate SHA-based internal tag
- name: Generate tag
id: tags
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
echo "tag=${{ env.IMAGE }}:sha-${SHORT_SHA}-amd64" >> $GITHUB_OUTPUT

- name: Build and push AMD64 Docker image
- name: Build and push AMD64 image
uses: docker/build-push-action@v6
with:
context: .
Expand All @@ -88,8 +74,8 @@ jobs:
platforms: linux/amd64
provenance: mode=max
sbom: true
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=gha,scope=docker-amd64
cache-to: type=gha,mode=max,scope=docker-amd64

build-arm64:
name: Build ARM64 Docker Image
Expand All @@ -98,19 +84,13 @@ jobs:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create docker-binary directory
run: mkdir -p docker-binary
- uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-unknown-linux-gnu

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@v2
with:
key: aarch64-unknown-linux-gnu-docker

Expand All @@ -123,32 +103,30 @@ jobs:
working-directory: crates/cli
env:
RUSTFLAGS: '-C target-cpu=neoverse-n1'
run: |
cargo build --release --target aarch64-unknown-linux-gnu
run: cargo build --release --target aarch64-unknown-linux-gnu

- name: Prepare binary for Docker
run: |
mkdir -p docker-binary
cp target/aarch64-unknown-linux-gnu/release/rrelayer_cli docker-binary/rrelayer_cli
chmod +x docker-binary/rrelayer_cli

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
- name: Log into registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate SHA-based internal tag
- name: Generate tag
id: tags
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
echo "tag=${{ env.IMAGE }}:sha-${SHORT_SHA}-arm64" >> $GITHUB_OUTPUT

- name: Build and push ARM64 Docker image
- name: Build and push ARM64 image
uses: docker/build-push-action@v6
with:
context: .
Expand All @@ -158,8 +136,8 @@ jobs:
platforms: linux/arm64
provenance: mode=max
sbom: true
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=gha,scope=docker-arm64
cache-to: type=gha,mode=max,scope=docker-arm64

create-manifest:
name: Create Multi-Arch Manifest
Expand All @@ -169,49 +147,37 @@ jobs:
contents: read
packages: write
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
- name: Log into registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
elif [ -n "${{ inputs.version }}" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=" >> $GITHUB_OUTPUT
fi

- name: Create and push multi-arch manifest
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
AMD64_IMAGE="${{ env.IMAGE }}:sha-${SHORT_SHA}-amd64"
ARM64_IMAGE="${{ env.IMAGE }}:sha-${SHORT_SHA}-arm64"

echo "Source images:"
echo " AMD64: $AMD64_IMAGE"
echo " ARM64: $ARM64_IMAGE"

VERSION="${{ inputs.version }}"

AMD64="${{ env.IMAGE }}:sha-${SHORT_SHA}-amd64"
ARM64="${{ env.IMAGE }}:sha-${SHORT_SHA}-arm64"
VERSION="${{ steps.version.outputs.version }}"

if [ -n "$VERSION" ]; then
# Release build: create version tag and latest tag
echo "Creating release manifests for version: $VERSION"

# Version tag (e.g., 1.2.3)
echo "Creating manifest for tag: $VERSION"
docker buildx imagetools create -t "${{ env.IMAGE }}:$VERSION" \
"$AMD64_IMAGE" \
"$ARM64_IMAGE"

# Latest tag
echo "Creating manifest for tag: latest"
docker buildx imagetools create -t "${{ env.IMAGE }}:latest" \
"$AMD64_IMAGE" \
"$ARM64_IMAGE"
docker buildx imagetools create -t "${{ env.IMAGE }}:${VERSION}" "$AMD64" "$ARM64"
docker buildx imagetools create -t "${{ env.IMAGE }}:latest" "$AMD64" "$ARM64"
else
# Non-release build (master): create master tag only
echo "Creating master manifest"
docker buildx imagetools create -t "${{ env.IMAGE }}:master" \
"$AMD64_IMAGE" \
"$ARM64_IMAGE"
docker buildx imagetools create -t "${{ env.IMAGE }}:edge" "$AMD64" "$ARM64"
fi

echo "Manifests created successfully"
24 changes: 19 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ members = [

[workspace.dependencies]
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
anyhow = "1.0.98"
alloy = { version = "1.1.3", features = ["full", "signer-mnemonic", "signer-keystore", "eips", "eip712"] }
alloy-rlp = "0.3.12"
alloy-eips = "1.1.3"
serde_json = "1"
serde_yaml = "0.9"
anyhow = "1"
thiserror = "2.0"
alloy = { version = "1.7", features = ["full", "signer-mnemonic", "signer-keystore", "eips", "eip712"] }
reqwest = { version = "0.13.2", features = ["json", "query"] }
dotenvy = "0.15.7"
tokio = { version = "1", features = ["full"] }
tokio-postgres = { version = "0.7", features = ["with-uuid-1", "with-chrono-0_4", "with-serde_json-1"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
async-trait = "0.1"
chrono = "0.4"
hex = "0.4"
base64 = "0.22"
rand = "0.10"
hmac = "0.12"
sha2 = "0.10"
regex = "1"

[profile.release]
lto = "fat"
Expand Down
22 changes: 10 additions & 12 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,24 @@ rrelayer = { path = "../sdk" }
# external dependencies
clap = { version = "4.4.11", features = ["derive"] }
dialoguer = "0.11"
regex = "1.5.4"
regex = { workspace = true }
colored = "2.0"
tokio = "1.35.1"
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120"
serde_yaml = "0.9.34"
thiserror = "1.0"
tokio = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
thiserror = { workspace = true }
prettytable = "0.10.0"
chrono = "0.4.41"
hex = "0.4.3"
chrono = { workspace = true }
hex = { workspace = true }
rpassword = "7.3"

alloy = { workspace = true, features = ["full", "signer-mnemonic", "eips", "eip712", "signer-keystore"] }
alloy-rlp = { workspace = true }
alloy-eips = { workspace = true }

# build
tikv-jemalloc-ctl = { version = "0.6.0", optional = true }
tikv-jemallocator = { version = "0.6.0", optional = true }
rand = "0.8.5"
rand = { workspace = true }

[features]
jemalloc = ["dep:tikv-jemallocator", "dep:tikv-jemalloc-ctl"]
jemalloc = ["dep:tikv-jemallocator", "dep:tikv-jemalloc-ctl"]
9 changes: 2 additions & 7 deletions crates/cli/src/commands/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::credentials::{self};
use crate::error::CliError;
use clap::Subcommand;
// use dialoguer::{Input, Password};
use rand::Rng;
use rand::distributions::Alphanumeric;
use rand::distr::{Alphanumeric, SampleString};

#[derive(Subcommand)]
pub enum AuthCommand {
Expand Down Expand Up @@ -46,11 +45,7 @@ pub async fn handle_auth_command(cmd: &AuthCommand) -> Result<(), CliError> {
list_profiles().await?;
}
AuthCommand::GenApiKey => {
let key = rand::thread_rng()
.sample_iter(&Alphanumeric)
.take(8)
.map(char::from)
.collect::<String>();
let key = Alphanumeric.sample_string(&mut rand::rng(), 8);
println!(
"API key generated - note you have to config it in the networks yaml - {}",
key
Expand Down
11 changes: 4 additions & 7 deletions crates/cli/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use std::{fs, path::Path};
use crate::project_location::ProjectLocation;
use crate::{commands::error::InitError, print_error_message, print_success_message};
use dialoguer::{Confirm, Input};
use rand::Rng;
use rand::distributions::Alphanumeric;
use rand::distr::{Alphanumeric, SampleString};
use rrelayer_core::network::ChainId;
use rrelayer_core::{
ApiConfig, NetworkSetupConfig, RawSigningProviderConfig, SetupConfig, SigningProvider,
Expand All @@ -25,11 +24,9 @@ fn write_gitignore(path: &Path) -> Result<(), WriteFileError> {
}

fn generate_random_credentials() -> (String, String) {
let username: String =
rand::thread_rng().sample_iter(&Alphanumeric).take(8).map(char::from).collect();

let password: String =
rand::thread_rng().sample_iter(&Alphanumeric).take(16).map(char::from).collect();
let mut rng = rand::rng();
let username = Alphanumeric.sample_string(&mut rng, 8);
let password = Alphanumeric.sample_string(&mut rng, 16);

(format!("development_username_{}", username), format!("development_password_{}", password))
}
Expand Down
Loading
Loading