mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Compare commits
3 Commits
nb-2025090
...
ab11ce513f
| Author | SHA1 | Date | |
|---|---|---|---|
| ab11ce513f | |||
| 37b852e810 | |||
| 51c43d6dbd |
37
.github/workflows/docker.yml
vendored
Normal file
37
.github/workflows/docker.yml
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
# Publishes the Docker image.
|
||||
|
||||
name: docker
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
|
||||
env:
|
||||
IMAGE_NAME: ${{ github.repository_owner }}/nanoreth
|
||||
CARGO_TERM_COLOR: always
|
||||
DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/nanoreth
|
||||
DOCKER_USERNAME: ${{ github.actor }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build and push as latest
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: rui314/setup-mold@v1
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-on-failure: true
|
||||
- name: Log in to Docker
|
||||
run: |
|
||||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin
|
||||
- name: Set up Docker builder
|
||||
run: |
|
||||
docker buildx create --use --name builder
|
||||
- name: Build and push nanoreth image
|
||||
run: make IMAGE_NAME=$IMAGE_NAME DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME PROFILE=maxperf docker-build-push-latest
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -9342,6 +9342,8 @@ dependencies = [
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"ureq",
|
||||
"vergen",
|
||||
"vergen-git2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
name = "reth_hl"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
[lib]
|
||||
name = "reth_hl"
|
||||
@ -166,3 +167,7 @@ client = [
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.20.0"
|
||||
|
||||
[build-dependencies]
|
||||
vergen = { version = "9.0.4", features = ["build", "cargo", "emit_and_set"] }
|
||||
vergen-git2 = "1.0.5"
|
||||
52
Makefile
52
Makefile
@ -1,6 +1,8 @@
|
||||
# Modifed from reth Makefile
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
GIT_SHA ?= $(shell git rev-parse HEAD)
|
||||
GIT_TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null)
|
||||
BIN_DIR = "dist/bin"
|
||||
|
||||
# List of features to use when building. Can be overridden via the environment.
|
||||
@ -17,6 +19,9 @@ PROFILE ?= release
|
||||
# Extra flags for Cargo
|
||||
CARGO_INSTALL_EXTRA_FLAGS ?=
|
||||
|
||||
# The docker image name
|
||||
DOCKER_IMAGE_NAME ?= ghcr.io/hl-archive-node/nanoreth
|
||||
|
||||
##@ Help
|
||||
|
||||
.PHONY: help
|
||||
@ -207,3 +212,50 @@ check-features:
|
||||
--package reth-primitives-traits \
|
||||
--package reth-primitives \
|
||||
--feature-powerset
|
||||
|
||||
##@ Docker
|
||||
|
||||
# Note: This requires a buildx builder with emulation support. For example:
|
||||
#
|
||||
# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64`
|
||||
# `docker buildx create --use --driver docker-container --name cross-builder`
|
||||
.PHONY: docker-build-push
|
||||
docker-build-push: ## Build and push a cross-arch Docker image tagged with the latest git tag.
|
||||
$(call docker_build_push,$(GIT_TAG),$(GIT_TAG))
|
||||
|
||||
# Note: This requires a buildx builder with emulation support. For example:
|
||||
#
|
||||
# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64`
|
||||
# `docker buildx create --use --driver docker-container --name cross-builder`
|
||||
.PHONY: docker-build-push-git-sha
|
||||
docker-build-push-git-sha: ## Build and push a cross-arch Docker image tagged with the latest git sha.
|
||||
$(call docker_build_push,$(GIT_SHA),$(GIT_SHA))
|
||||
|
||||
# Note: This requires a buildx builder with emulation support. For example:
|
||||
#
|
||||
# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64`
|
||||
# `docker buildx create --use --driver docker-container --name cross-builder`
|
||||
.PHONY: docker-build-push-latest
|
||||
docker-build-push-latest: ## Build and push a cross-arch Docker image tagged with the latest git tag and `latest`.
|
||||
$(call docker_build_push,$(GIT_TAG),latest)
|
||||
|
||||
# Note: This requires a buildx builder with emulation support. For example:
|
||||
#
|
||||
# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64`
|
||||
# `docker buildx create --use --name cross-builder`
|
||||
.PHONY: docker-build-push-nightly
|
||||
docker-build-push-nightly: ## Build and push cross-arch Docker image tagged with the latest git tag with a `-nightly` suffix, and `latest-nightly`.
|
||||
$(call docker_build_push,nightly,nightly)
|
||||
|
||||
# Create a Docker image using the main Dockerfile
|
||||
define docker_build_push
|
||||
docker buildx build --file ./Dockerfile . \
|
||||
--platform linux/amd64 \
|
||||
--tag $(DOCKER_IMAGE_NAME):$(1) \
|
||||
--tag $(DOCKER_IMAGE_NAME):$(2) \
|
||||
--build-arg BUILD_PROFILE="$(PROFILE)" \
|
||||
--build-arg FEATURES="jemalloc,asm-keccak" \
|
||||
--build-arg RUSTFLAGS="-C target-cpu=native" \
|
||||
--provenance=false \
|
||||
--push
|
||||
endef
|
||||
|
||||
91
build.rs
Normal file
91
build.rs
Normal file
@ -0,0 +1,91 @@
|
||||
use std::{env, error::Error};
|
||||
use vergen::{BuildBuilder, CargoBuilder, Emitter};
|
||||
use vergen_git2::Git2Builder;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut emitter = Emitter::default();
|
||||
|
||||
let build_builder = BuildBuilder::default().build_timestamp(true).build()?;
|
||||
|
||||
emitter.add_instructions(&build_builder)?;
|
||||
|
||||
let cargo_builder = CargoBuilder::default().features(true).target_triple(true).build()?;
|
||||
|
||||
emitter.add_instructions(&cargo_builder)?;
|
||||
|
||||
let git_builder =
|
||||
Git2Builder::default().describe(false, true, None).dirty(true).sha(false).build()?;
|
||||
|
||||
emitter.add_instructions(&git_builder)?;
|
||||
|
||||
emitter.emit_and_set()?;
|
||||
let sha = env::var("VERGEN_GIT_SHA")?;
|
||||
let sha_short = &sha[0..7];
|
||||
|
||||
let is_dirty = env::var("VERGEN_GIT_DIRTY")? == "true";
|
||||
// > git describe --always --tags
|
||||
// if not on a tag: v0.2.0-beta.3-82-g1939939b
|
||||
// if on a tag: v0.2.0-beta.3
|
||||
let not_on_tag = env::var("VERGEN_GIT_DESCRIBE")?.ends_with(&format!("-g{sha_short}"));
|
||||
let version_suffix = if is_dirty || not_on_tag { "-dev" } else { "" };
|
||||
println!("cargo:rustc-env=RETH_HL_VERSION_SUFFIX={version_suffix}");
|
||||
|
||||
// Set short SHA
|
||||
println!("cargo:rustc-env=VERGEN_GIT_SHA_SHORT={}", &sha[..8]);
|
||||
|
||||
// Set the build profile
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let profile = out_dir.rsplit(std::path::MAIN_SEPARATOR).nth(3).unwrap();
|
||||
println!("cargo:rustc-env=RETH_HL_BUILD_PROFILE={profile}");
|
||||
|
||||
// Set formatted version strings
|
||||
let pkg_version = env!("CARGO_PKG_VERSION");
|
||||
|
||||
// The short version information for reth.
|
||||
// - The latest version from Cargo.toml
|
||||
// - The short SHA of the latest commit.
|
||||
// Example: 0.1.0 (defa64b2)
|
||||
println!("cargo:rustc-env=RETH_HL_SHORT_VERSION={pkg_version}{version_suffix} ({sha_short})");
|
||||
|
||||
// LONG_VERSION
|
||||
// The long version information for reth.
|
||||
//
|
||||
// - The latest version from Cargo.toml + version suffix (if any)
|
||||
// - The full SHA of the latest commit
|
||||
// - The build datetime
|
||||
// - The build features
|
||||
// - The build profile
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// ```text
|
||||
// Version: 0.1.0
|
||||
// Commit SHA: defa64b2
|
||||
// Build Timestamp: 2023-05-19T01:47:19.815651705Z
|
||||
// Build Features: jemalloc
|
||||
// Build Profile: maxperf
|
||||
// ```
|
||||
println!("cargo:rustc-env=RETH_HL_LONG_VERSION_0=Version: {pkg_version}{version_suffix}");
|
||||
println!("cargo:rustc-env=RETH_HL_LONG_VERSION_1=Commit SHA: {sha}");
|
||||
println!(
|
||||
"cargo:rustc-env=RETH_HL_LONG_VERSION_2=Build Timestamp: {}",
|
||||
env::var("VERGEN_BUILD_TIMESTAMP")?
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=RETH_HL_LONG_VERSION_3=Build Features: {}",
|
||||
env::var("VERGEN_CARGO_FEATURES")?
|
||||
);
|
||||
println!("cargo:rustc-env=RETH_HL_LONG_VERSION_4=Build Profile: {profile}");
|
||||
|
||||
// The version information for reth formatted for P2P (devp2p).
|
||||
// - The latest version from Cargo.toml
|
||||
// - The target triple
|
||||
//
|
||||
// Example: reth/v0.1.0-alpha.1-428a6dc2f/aarch64-apple-darwin
|
||||
println!(
|
||||
"cargo:rustc-env=RETH_HL_P2P_CLIENT_VERSION={}",
|
||||
format_args!("reth/v{pkg_version}-{sha_short}/{}", env::var("VERGEN_CARGO_TARGET_TRIPLE")?)
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -5,5 +5,6 @@ mod evm;
|
||||
mod hardforks;
|
||||
pub mod node;
|
||||
pub mod pseudo_peer;
|
||||
pub mod version;
|
||||
|
||||
pub use node::primitives::{HlBlock, HlBlockBody, HlPrimitives};
|
||||
|
||||
@ -31,6 +31,9 @@ fn main() -> eyre::Result<()> {
|
||||
std::env::set_var("RUST_BACKTRACE", "1");
|
||||
}
|
||||
|
||||
// Initialize custom version metadata before parsing CLI so --version uses reth-hl values
|
||||
reth_hl::version::init_reth_hl_version();
|
||||
|
||||
Cli::<HlChainSpecParser, HlNodeArgs>::parse().run(
|
||||
|builder: WithLaunchContext<NodeBuilder<Arc<DatabaseEnv>, HlChainSpec>>,
|
||||
ext: HlNodeArgs| async move {
|
||||
|
||||
35
src/version.rs
Normal file
35
src/version.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use reth_node_core::version::{try_init_version_metadata, RethCliVersionConsts};
|
||||
|
||||
pub fn init_reth_hl_version() {
|
||||
let cargo_pkg_version = env!("CARGO_PKG_VERSION").to_string();
|
||||
|
||||
let short = env!("RETH_HL_SHORT_VERSION").to_string();
|
||||
let long = format!(
|
||||
"{}\n{}\n{}\n{}\n{}",
|
||||
env!("RETH_HL_LONG_VERSION_0"),
|
||||
env!("RETH_HL_LONG_VERSION_1"),
|
||||
env!("RETH_HL_LONG_VERSION_2"),
|
||||
env!("RETH_HL_LONG_VERSION_3"),
|
||||
env!("RETH_HL_LONG_VERSION_4"),
|
||||
);
|
||||
let p2p = env!("RETH_HL_P2P_CLIENT_VERSION").to_string();
|
||||
|
||||
let meta = RethCliVersionConsts {
|
||||
name_client: Cow::Borrowed("reth_hl"),
|
||||
cargo_pkg_version: Cow::Owned(cargo_pkg_version.clone()),
|
||||
vergen_git_sha_long: Cow::Owned(env!("VERGEN_GIT_SHA").to_string()),
|
||||
vergen_git_sha: Cow::Owned(env!("VERGEN_GIT_SHA_SHORT").to_string()),
|
||||
vergen_build_timestamp: Cow::Owned(env!("VERGEN_BUILD_TIMESTAMP").to_string()),
|
||||
vergen_cargo_target_triple: Cow::Owned(env!("VERGEN_CARGO_TARGET_TRIPLE").to_string()),
|
||||
vergen_cargo_features: Cow::Owned(env!("VERGEN_CARGO_FEATURES").to_string()),
|
||||
short_version: Cow::Owned(short),
|
||||
long_version: Cow::Owned(long),
|
||||
build_profile_name: Cow::Owned(env!("RETH_HL_BUILD_PROFILE").to_string()),
|
||||
p2p_client_version: Cow::Owned(p2p),
|
||||
extra_data: Cow::Owned(format!("reth_hl/v{}/{}", cargo_pkg_version, std::env::consts::OS)),
|
||||
};
|
||||
|
||||
let _ = try_init_version_metadata(meta);
|
||||
}
|
||||
Reference in New Issue
Block a user