diff --git a/.gitignore b/.gitignore index 98cbb2478..db24b6610 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,17 @@ +# log files *_dump.log logs/ -target/ + +# environment secrets +.env + +# IDEs .vscode .idea + +# build artifacts +target/ +dist/ + +# other .DS_Store -.env diff --git a/RELEASE.md b/RELEASE.md index 52b498c02..87065304c 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -16,8 +16,6 @@ Pay special attention to the `README` and `docker-compose` files. For instance, for the Bolt sidecar this is in `bolt-sidecar/Cargo.toml`. Similar changes should be made in the other packages getting updated. -We don't currently keep track of the version for flashbots forks. - Next, update the version of the Docker images used in any `docker-compose` files. These currently only live inside the `testnets/` dir. @@ -29,9 +27,10 @@ We use the built-in Github changelog feature to generate the changelog. ## 3. Build new Docker images -You can build new Docker images with the `just release ` recipe. +You can build new Docker images with the `just build-and-push-all-images ` recipe. -Example: `just release v0.2.0-alpha` will build and push the Docker images +Example: `just build-and-push-all-images v0.2.0-alpha` will build and push the Docker images for all Bolt components with the tag `v0.2.0-alpha` for both `arm64` and `amd64` -architectures. This can take a long time... We recommend building from an ARM machine -because cross-compiling from x86 into ARM is slow as hell. +architectures. This can take a long time. + +Since we use cross compilation, we recommend running this from an x86_64 linux box. diff --git a/bolt-boost/Cargo.lock b/bolt-boost/Cargo.lock index 05554897b..885e69e6d 100644 --- a/bolt-boost/Cargo.lock +++ b/bolt-boost/Cargo.lock @@ -80,10 +80,11 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.1.36" +version = "0.1.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c225801d42099570d0674701dddd4142f0ef715282aeb5985042e2ec962df7" +checksum = "18c5c520273946ecf715c0010b4e3503d7eba9893cd9ce6b7fff5654c4a3c470" dependencies = [ + "alloy-primitives 0.8.5", "num_enum", "strum", ] @@ -498,9 +499,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.5" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68e7f6e8fe5b443f82b3f1e15abfa191128f71569148428e49449d01f6f49e8b" +checksum = "9343289b4a7461ed8bab8618504c995c049c082b70c7332efd7b32125633dc05" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -512,9 +513,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.5" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b96ce28d2fde09abb6135f410c41fad670a3a770b6776869bd852f1df102e6f" +checksum = "4222d70bec485ceccc5d8fd4f2909edd65b5d5e43d4aca0b5dcee65d519ae98f" dependencies = [ "alloy-sol-macro-input", "const-hex", @@ -530,9 +531,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.5" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "906746396a8296537745711630d9185746c0b50c033d5e9d18b0a6eba3d53f90" +checksum = "2e17f2677369571b976e51ea1430eb41c3690d344fef567b840bfc0b01b6f83a" dependencies = [ "const-hex", "dunce", @@ -545,9 +546,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.5" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc85178909a49c8827ffccfc9103a7ce1767ae66a801b69bdc326913870bf8e6" +checksum = "aa64d80ae58ffaafdff9d5d84f58d03775f66c84433916dc9a64ed16af5755da" dependencies = [ "serde", "winnow", @@ -1196,7 +1197,7 @@ dependencies = [ "tokio", "tracing", "url", - "uuid 1.10.0", + "uuid 1.11.0", ] [[package]] @@ -1895,6 +1896,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "foreign-types" version = "0.3.2" @@ -2106,6 +2113,11 @@ name = "hashbrown" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] [[package]] name = "hashlink" @@ -2539,11 +2551,11 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.0", ] [[package]] @@ -2935,18 +2947,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", @@ -3666,9 +3678,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.10.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9720086b3357bcb44fce40117d769a4d068c70ecfa190850a980a71755f66fcc" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" dependencies = [ "base64", "chrono", @@ -3684,9 +3696,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.10.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f1abbfe725f27678f4663bcacb75a83e829fd464c25d78dd038a3a29e307cec" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ "darling 0.20.10", "proc-macro2", @@ -3718,7 +3730,6 @@ dependencies = [ "cpufeatures", "digest 0.9.0", "opaque-debug", - "sha2-asm", ] [[package]] @@ -3732,15 +3743,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha2-asm" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b845214d6175804686b2bd482bcffe96651bb2d1200742b712003504a2dac1ab" -dependencies = [ - "cc", -] - [[package]] name = "sha3" version = "0.10.8" @@ -4010,9 +4012,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.5" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab661c8148c2261222a4d641ad5477fd4bea79406a99056096a0b41b35617a5" +checksum = "f76fe0a3e1476bdaa0775b9aec5b869ed9520c2b2fedfe9c6df3618f8ea6290b" dependencies = [ "paste", "proc-macro2", @@ -4613,9 +4615,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom", "rand", diff --git a/bolt-boost/Cargo.toml b/bolt-boost/Cargo.toml index e4c1e02a6..c813a2aee 100644 --- a/bolt-boost/Cargo.toml +++ b/bolt-boost/Cargo.toml @@ -3,6 +3,10 @@ name = "bolt-boost" version = "0.3.0-alpha" edition = "2021" +[profile.release] +lto = true +debug = true + [dependencies] # core tokio = { version = "1", features = ["full"] } @@ -15,9 +19,7 @@ thiserror = "1.0.63" reqwest = "0.12.7" # crypto -ssz_rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "ec3073e", features = [ - "sha2-asm", -] } +ssz_rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "ec3073e" } tree_hash = "0.8" # tracing & metrics diff --git a/bolt-boost/Cross.toml b/bolt-boost/Cross.toml new file mode 100644 index 000000000..96d090f34 --- /dev/null +++ b/bolt-boost/Cross.toml @@ -0,0 +1,7 @@ +[build] +pre-build = [ + # We depend on openssl for the build, so we need to install its cross-compiled version + # more info at: https://github.com/cross-rs/cross/wiki/Configuration#build + "dpkg --add-architecture $CROSS_DEB_ARCH", + "apt-get update && apt-get --assume-yes --no-install-recommends install libssl-dev:$CROSS_DEB_ARCH" +] diff --git a/bolt-sidecar/Cargo.toml b/bolt-sidecar/Cargo.toml index 05dbfd111..584fa563e 100644 --- a/bolt-sidecar/Cargo.toml +++ b/bolt-sidecar/Cargo.toml @@ -4,6 +4,10 @@ version = "0.3.0-alpha" edition = "2021" default-run = "bolt-sidecar" +[profile.release] +lto = true +debug = true + [dependencies] # core clap = { version = "4.5.20", features = ["derive", "env"] } diff --git a/bolt-sidecar/Cross.toml b/bolt-sidecar/Cross.toml new file mode 100644 index 000000000..c707328e6 --- /dev/null +++ b/bolt-sidecar/Cross.toml @@ -0,0 +1,11 @@ +[build] +pre-build = [ + # We depend on openssl for the build, so we need to install its cross-compiled version + # more info at: https://github.com/cross-rs/cross/wiki/Configuration#build + "dpkg --add-architecture $CROSS_DEB_ARCH", + "apt-get update && apt-get --assume-yes --no-install-recommends install libssl-dev:$CROSS_DEB_ARCH", + + # Update the default gcc and g++ to 10 to avoid a bug in gcc 9 that causes a build failure + # more info at: https://github.com/cross-rs/cross/issues/1565#issuecomment-2483968180 + "apt-get --assume-yes --no-install-recommends install gcc-10 g++-10 && ln -sf /usr/bin/gcc-10 /usr/bin/gcc && ln -sf /usr/bin/g++-10 /usr/bin/g++" +] diff --git a/justfile b/justfile index c48465010..0c06cc950 100644 --- a/justfile +++ b/justfile @@ -136,23 +136,51 @@ send-blob-preconf count='1': --count {{count}} # build all the docker images locally -build-images: - @just build-sidecar - @just build-bolt-boost +build-local-images: + @just build-local-sidecar + @just build-local-bolt-boost # build the docker image for the bolt sidecar [private] -build-sidecar: +build-local-sidecar: cd bolt-sidecar && docker build -t ghcr.io/chainbound/bolt-sidecar:0.1.0 . --load # build the docker image for bolt-boost [private] -build-bolt-boost: +build-local-bolt-boost: cd bolt-boost && docker build -t ghcr.io/chainbound/bolt-boost:0.1.0 . --load -# build and push multi-platform docker images to GHCR with the provided tag -[confirm("are you sure? this will build and push new images on ghcr.io")] -release tag: - chmod +x ./scripts/check_version_bumps.sh && ./scripts/check_version_bumps.sh {{tag}} - cd bolt-sidecar && docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/chainbound/bolt-sidecar:{{tag}} --push . - cd bolt-boost && docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/chainbound/bolt-boost:{{tag}} --push . + +# Cross platform compilation with cargo cross. +# Install cross with: `cargo install cross --git https://github.com/cross-rs/cross`. +# +# Troubleshooting tips: +# * We have to clean the target directory before building for different targets because +# of a rustc incremental compilation bug. See: https://github.com/cross-rs/cross/issues/724#issuecomment-1484065725 +# * If incurring into issues related to building `aws-lc-rs`, check this out: +# https://github.com/cross-rs/cross/issues/1565#issuecomment-2483968180 +# * If incurring into issues related to building `sha2-asm`, make sure the "sha2-asm" feature +# is disabled in the `Cargo.toml` file you are trying to build. +# +# build the cross platform binaries for a package by name. available: "bolt-sidecar", "bolt-boost". +[private] +cross-compile package target_arch release_dir: + cd {{package}} && cargo clean && cross build --release --target {{target_arch}} + mkdir -p {{release_dir}} && cp {{package}}/target/{{target_arch}}/release/{{package}} {{release_dir}} + +# build and push multi-platform docker images to GHCR for a package. available: "bolt-sidecar", "bolt-boost". +build-and-push-image package tag: + @just cross-compile {{package}} x86_64-unknown-linux-gnu amd64 + @just cross-compile {{package}} aarch64-unknown-linux-gnu arm64 + + docker buildx build \ + --build-arg BINARY={{package}} \ + --file ./scripts/cross.Dockerfile \ + --platform linux/amd64,linux/arm64 \ + --tag ghcr.io/chainbound/{{package}}:{{tag}} \ + --push . + +# build and push all the available packages to GHCR with the provided tag +build-and-push-all-images tag='latest': + @just build-and-push-image bolt-sidecar {{tag}} + @just build-and-push-image bolt-boost {{tag}} diff --git a/scripts/cross.Dockerfile b/scripts/cross.Dockerfile new file mode 100644 index 000000000..3079674b7 --- /dev/null +++ b/scripts/cross.Dockerfile @@ -0,0 +1,18 @@ +# This image is meant to enable cross-architecture builds. +# It assumes the binary has already been compiled for `$TARGETPLATFORM` and is +# locatable in `./dist/bin/$TARGETARCH/$BINARY`. + +FROM --platform=$TARGETPLATFORM ubuntu:22.04 + +LABEL org.opencontainers.image.source=https://github.com/chainbound/bolt +LABEL org.opencontainers.image.licenses="MIT" + +# Filled by docker buildx +ARG TARGETARCH + +# Should be set by the caller when building the image +ARG BINARY + +COPY ./dist/bin/$TARGETARCH/$BINARY /usr/local/bin/bolt + +ENTRYPOINT ["/usr/local/bin/bolt"]