Skip to content

Commit

Permalink
chore: add babylon network binary (#3473)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeryz authored Jan 9, 2025
2 parents 83ad089 + 7af1f79 commit 45561d9
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 0 deletions.
56 changes: 56 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@
url = "github:cosmos/ics23";
flake = false;
};
# for chains that require blst (babylon)
blst = {
url = "github:supranational/blst?rev=3dd0f804b1819e5d03fb22ca2e6fac105932043a";
flake = false;
};
bls-eth-go = {
url = "git+https://github.com/herumi/bls-eth-go-binary?ref=refs/tags/v1.33.0&submodules=1";
flake = false;
};
cosmosproto = {
url = "github:cosmos/cosmos-proto?ref=refs/tags/v1.0.0-beta.5";
flake = false;
Expand All @@ -77,6 +86,10 @@
url = "github:osmosis-labs/osmosis/v24.0.0-rc0";
flake = false;
};
babylon = {
url = "github:babylonlabs-io/babylon/v1.0.0-rc.3";
flake = false;
};

public-awesome-launchpad = {
type = "github";
Expand Down Expand Up @@ -215,6 +228,7 @@
./tools/tools.nix
./tools/wasm-light-client.nix
./tools/libwasmvm/libwasmvm.nix
./tools/libblst/libblst.nix
./tools/tidy/tidy.nix
./tools/rust/rust.nix
./tools/rust/crane.nix
Expand All @@ -228,6 +242,7 @@
./networks/simulation/simd.nix
./networks/stargaze.nix
./networks/osmosis.nix
./networks/babylon.nix
./e2e/all-tests.nix
./e2e/e2e.nix
./devnet-compose/devnet-compose.nix
Expand Down
51 changes: 51 additions & 0 deletions networks/babylon.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{ inputs, ... }:
{
perSystem =
{
pkgs,
goPkgs,
self',
crane,
system,
ensureAtRepositoryRoot,
dbg,
...
}:
{
packages = {
babylond = goPkgs.pkgsStatic.buildGo123Module (
{
name = "babylond";
src = inputs.babylon;
vendorHash = "sha256-wfvcbBdWBo2jYTiRymHDxL5f6X9RXr2scGuKNc5OaAY=";
doCheck = false;
doInstallCheck = false;
meta.mainProgram = "babylond";
# CGO_ENABLED = 0;
subPackages = [ "./cmd/babylond" ];
buildTags = [ "netgo" ];
}
// (
let
CGO_CFLAGS = "-I${self'.packages.libblst}/include -I${self'.packages.libblst.src}/src -I${self'.packages.libblst.src}/build -O";
CGO_LDFLAGS = "-z noexecstack -static -L${goPkgs.musl}/lib -L${self'.packages.libwasmvm-2_1_3}/lib -s -w";
in
if pkgs.stdenv.isLinux then
{
inherit CGO_CFLAGS;
inherit CGO_LDFLAGS;
# Statically link if we're on linux
nativeBuildInputs = [
pkgs.musl
];
ldflags = [
"-linkmode external"
];
}
else
{ }
)
);
};
};
}
71 changes: 71 additions & 0 deletions tools/libblst/libblst.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{ inputs, ... }:
{
perSystem =
{ pkgs, ... }:
let
enableShared = !pkgs.stdenv.hostPlatform.isStatic;
in
with pkgs;
{
packages.libblst = stdenv.mkDerivation rec {
pname = "blst";
version = inputs.blst.shortRev;
src = inputs.blst;
buildPhase =
''
./build.sh
''
+ lib.optionalString enableShared ''
./build.sh -shared
'';
installPhase = ''
mkdir -p $out/{lib,include}
for lib in libblst.{a,so,dylib}; do
if [ -f $lib ]; then
cp $lib $out/lib/
fi
done
cp bindings/{blst.h,blst_aux.h} $out/include
for lib in blst.dll; do
if [ -f $lib ]; then
mkdir -p $out/bin
cp $lib $out/bin/
fi
done
mkdir -p $out/lib/pkgconfig
cat <<EOF > $out/lib/pkgconfig/libblst.pc
prefix=$out
exec_prefix=\''${prefix}
libdir=\''${exec_prefix}/lib
includedir=\''${prefix}/include
Name: libblst
Description: ${meta.description}
URL: ${meta.homepage}
Version: ${version}
Cflags: -I\''${includedir}
Libs: -L\''${libdir} -lblst
Libs.private:
EOF
'';
# ensure we have the right install id set. Otherwise the library
# wouldn't be found during install. The alternative would be to work
# lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libblst.dylib";
# into the setup.sh
postFixup = lib.optionalString (stdenv.isDarwin && enableShared) ''
install_name_tool -id $out/lib/libblst.dylib $out/lib/libblst.dylib
'';
enableParallelBuilding = true;
doCheck = true;
meta = with lib; {
description = "Multilingual BLS12-381 signature library";
homepage = "https://github.com/supranational/blst";
license = licenses.isc;
platforms = platforms.all;
};
};
};
}

0 comments on commit 45561d9

Please sign in to comment.