Skip to content

Commit

Permalink
Merge branch 'main' into cometbft
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang authored Nov 6, 2024
2 parents 3493521 + 742d12f commit f1acbc9
Show file tree
Hide file tree
Showing 23 changed files with 652 additions and 425 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ jobs:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
if: steps.changed-files.outputs.any_changed == 'true'
- run: nix-shell -I nixpkgs=./nix -p nixpkgs-fmt --run "make lint-nix"
- run: nix-shell -I nixpkgs=./nix -p nixfmt-rfc-style --run "make lint-nix"
if: steps.changed-files.outputs.any_changed == 'true'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ lint-py:
--format="::error file=%(path)s,line=%(row)d,col=%(col)d::%(path)s:%(row)d:%(col)d: %(code)s %(text)s" \

lint-nix:
find . -name "*.nix" ! -path './integration_tests/contracts/*' ! -path "./contracts/*" | xargs nixpkgs-fmt --check
find . -name "*.nix" ! -path './integration_tests/contracts/*' ! -path "./contracts/*" | xargs nixfmt -c

.PHONY: lint lint-fix lint-py

Expand Down
78 changes: 49 additions & 29 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
{ lib
, stdenv
, buildGoApplication
, nix-gitignore
, buildPackages
, coverage ? false # https://tip.golang.org/doc/go1.20#cover
, rocksdb
, network ? "mainnet" # mainnet|testnet
, rev ? "dirty"
, static ? stdenv.hostPlatform.isStatic
, nativeByteOrder ? true # nativeByteOrder mode will panic on big endian machines
{
lib,
stdenv,
buildGoApplication,
nix-gitignore,
buildPackages,
coverage ? false, # https://tip.golang.org/doc/go1.20#cover
rocksdb,
network ? "mainnet", # mainnet|testnet
rev ? "dirty",
static ? stdenv.hostPlatform.isStatic,
nativeByteOrder ? true, # nativeByteOrder mode will panic on big endian machines
}:
let
version = "v1.4.0";
pname = "cronosd";
tags = [ "ledger" "netgo" network "rocksdb" "grocksdb_no_link" "pebbledb" "objstore" ] ++ lib.optionals nativeByteOrder [ "nativebyteorder" ];
tags = [
"ledger"
"netgo"
network
"rocksdb"
"grocksdb_no_link"
"pebbledb"
"objstore"
] ++ lib.optionals nativeByteOrder [ "nativebyteorder" ];
ldflags = lib.concatStringsSep "\n" ([
"-X github.com/cosmos/cosmos-sdk/version.Name=cronos"
"-X github.com/cosmos/cosmos-sdk/version.AppName=${pname}"
Expand All @@ -24,29 +33,40 @@ let
buildInputs = [ rocksdb ];
in
buildGoApplication rec {
inherit pname version buildInputs tags ldflags;
src = (nix-gitignore.gitignoreSourcePure [
"/*" # ignore all, then add whitelists
"!/x/"
"!/app/"
"!/cmd/"
"!/client/"
"!/versiondb/"
"!/memiavl/"
"!/store/"
"!go.mod"
"!go.sum"
"!gomod2nix.toml"
] ./.);
inherit
pname
version
buildInputs
tags
ldflags
;
src = (
nix-gitignore.gitignoreSourcePure [
"/*" # ignore all, then add whitelists
"!/x/"
"!/app/"
"!/cmd/"
"!/client/"
"!/versiondb/"
"!/memiavl/"
"!/store/"
"!go.mod"
"!go.sum"
"!gomod2nix.toml"
] ./.
);
modules = ./gomod2nix.toml;
pwd = src; # needed to support replace
subPackages = [ "cmd/cronosd" ];
buildFlags = lib.optionalString coverage "-cover";
CGO_ENABLED = "1";
CGO_LDFLAGS = lib.optionalString (rocksdb != null) (
if static then "-lrocksdb -pthread -lstdc++ -ldl -lzstd -lsnappy -llz4 -lbz2 -lz"
else if stdenv.hostPlatform.isWindows then "-lrocksdb-shared"
else "-lrocksdb -pthread -lstdc++ -ldl"
if static then
"-lrocksdb -pthread -lstdc++ -ldl -lzstd -lsnappy -llz4 -lbz2 -lz"
else if stdenv.hostPlatform.isWindows then
"-lrocksdb-shared"
else
"-lrocksdb -pthread -lstdc++ -ldl"
);

postFixup = lib.optionalString (stdenv.isDarwin && rocksdb != null) ''
Expand Down
93 changes: 49 additions & 44 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,60 +18,65 @@
};
};

outputs = { self, nixpkgs, nix-bundle-exe, gomod2nix, flake-utils, poetry2nix }:
outputs =
{
self,
nixpkgs,
nix-bundle-exe,
gomod2nix,
flake-utils,
poetry2nix,
}:
let
rev = self.shortRev or "dirty";
mkApp = drv: {
type = "app";
program = "${drv}/bin/${drv.meta.mainProgram}";
};
in
(flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = self.overlays.default;
config = { };
(flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = self.overlays.default;
config = { };
};
in
rec {
packages = pkgs.cronos-matrix // {
inherit (pkgs) rocksdb testground-image;
};
apps = {
cronosd = mkApp packages.cronosd;
cronosd-testnet = mkApp packages.cronosd-testnet;
stateless-testcase = {
type = "app";
program = "${pkgs.benchmark-testcase}/bin/stateless-testcase";
};
in
rec {
packages = pkgs.cronos-matrix // {
inherit (pkgs) rocksdb testground-image;
};
defaultPackage = packages.cronosd;
defaultApp = apps.cronosd;
devShells = rec {
default = pkgs.mkShell {
buildInputs = [
defaultPackage.go
pkgs.gomod2nix
pkgs.nixfmt-rfc-style
];
};
apps = {
cronosd = mkApp packages.cronosd;
cronosd-testnet = mkApp packages.cronosd-testnet;
stateless-testcase = {
type = "app";
program = "${pkgs.benchmark-testcase}/bin/stateless-testcase";
};
rocksdb = pkgs.mkShell {
buildInputs = default.buildInputs ++ [
pkgs.rocksdb
pkgs.rocksdb.tools
];
};
defaultPackage = packages.cronosd;
defaultApp = apps.cronosd;
devShells = rec {
default = pkgs.mkShell {
buildInputs = [
defaultPackage.go
pkgs.gomod2nix
];
};
rocksdb = pkgs.mkShell {
buildInputs = default.buildInputs ++ [
pkgs.rocksdb
pkgs.rocksdb.tools
];
};
full = pkgs.mkShell {
buildInputs = rocksdb.buildInputs ++ [
pkgs.test-env
];
};
};
legacyPackages = pkgs;
}
)
) // {
full = pkgs.mkShell { buildInputs = rocksdb.buildInputs ++ [ pkgs.test-env ]; };
};
legacyPackages = pkgs;
}
))
// {
overlays.default = [
(import ./nix/build_overlay.nix)
poetry2nix.overlays.default
Expand Down
11 changes: 6 additions & 5 deletions integration_tests/configs/broken-cronosd.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{ pkgs ? import ../../nix { } }:
let cronosd = (pkgs.callPackage ../../. { });
{
pkgs ? import ../../nix { },
}:
let
cronosd = (pkgs.callPackage ../../. { });
in
cronosd.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [ ] ++ [
./broken-cronosd.patch
];
patches = oldAttrs.patches or [ ] ++ [ ./broken-cronosd.patch ];
})
53 changes: 37 additions & 16 deletions integration_tests/configs/upgrade-test-package.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,47 @@
let
pkgs = import ../../nix { };
fetchFlake = repo: rev: (pkgs.flake-compat {
src = {
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz";
inherit rev;
shortRev = builtins.substring 0 7 rev;
};
}).defaultNix;
fetchFlake =
repo: rev:
(pkgs.flake-compat {
src = {
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz";
inherit rev;
shortRev = builtins.substring 0 7 rev;
};
}).defaultNix;
# v1.0.15
releasedGenesis = (fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default;
releasedGenesis =
(fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default;
# release/v1.1.x
released1_1 = (fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default;
released1_1 =
(fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default;
# release/v1.2.x
released1_2 = (fetchFlake "crypto-org-chain/cronos" "1aea999eef67a0a01b22422bad94b36e45b9759a").default;
released1_2 =
(fetchFlake "crypto-org-chain/cronos" "1aea999eef67a0a01b22422bad94b36e45b9759a").default;
# release/v1.3.x
released1_3 = (fetchFlake "crypto-org-chain/cronos" "e1d819c862b30f0ce978baf2addb12516568639e").default;
released1_3 =
(fetchFlake "crypto-org-chain/cronos" "e1d819c862b30f0ce978baf2addb12516568639e").default;
current = pkgs.callPackage ../../. { };
in
pkgs.linkFarm "upgrade-test-package" [
{ name = "genesis"; path = releasedGenesis; }
{ name = "v1.1.0"; path = released1_1; }
{ name = "v1.2"; path = released1_2; }
{ name = "v1.3"; path = released1_3; }
{ name = "v1.4"; path = current; }
{
name = "genesis";
path = releasedGenesis;
}
{
name = "v1.1.0";
path = released1_1;
}
{
name = "v1.2";
path = released1_2;
}
{
name = "v1.3";
path = released1_3;
}
{
name = "v1.4";
path = current;
}
]
7 changes: 5 additions & 2 deletions integration_tests/shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{ system ? builtins.currentSystem, pkgs ? import ../nix { inherit system; } }:
{
system ? builtins.currentSystem,
pkgs ? import ../nix { inherit system; },
}:
let
renameExe = pkgs.callPackage ../nix/rename-exe.nix { };
in
Expand All @@ -18,7 +21,7 @@ pkgs.mkShell {
(renameExe pkgs.solc-static-versions.solc_0_6_8 "solc-0.6.8" "solc06")
(renameExe pkgs.solc-static-versions.solc_0_8_21 "solc-0.8.21" "solc08")
pkgs.test-env
pkgs.nixpkgs-fmt
pkgs.nixfmt-rfc-style
pkgs.rocksdb
pkgs.chain-maind
pkgs.hermes
Expand Down
66 changes: 34 additions & 32 deletions nix/bundle-win-exe.nix
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
{ runCommand
, windows
, stdenv
, rocksdb
, bzip2
, lz4
, snappy
, zstd
, zlib
, cronosd
{
runCommand,
windows,
stdenv,
rocksdb,
bzip2,
lz4,
snappy,
zstd,
zlib,
cronosd,
}:
runCommand "tarball-${cronosd.name}"
{
# manually enumerate the runtime dependencies of cronosd on mingwW64
deps = [
"${rocksdb}/bin/librocksdb-shared.dll"
"${snappy}/bin/libsnappy.dll"
"${lz4.out}/lib/liblz4.dll"
"${bzip2.bin}/bin/libbz2-1.dll"
"${zlib}/bin/zlib1.dll"
"${zstd.bin}/bin/libzstd.dll"
"${windows.mingw_w64_pthreads}/bin/libwinpthread-1.dll"
"${windows.mcfgthreads}/bin/libmcfgthread-1.dll"
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libgcc_s_seh-1.dll"
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libstdc++-6.dll"
];
} ''
mkdir -p $out
for so in $deps
do
cp $so $out/
done
{
# manually enumerate the runtime dependencies of cronosd on mingwW64
deps = [
"${rocksdb}/bin/librocksdb-shared.dll"
"${snappy}/bin/libsnappy.dll"
"${lz4.out}/lib/liblz4.dll"
"${bzip2.bin}/bin/libbz2-1.dll"
"${zlib}/bin/zlib1.dll"
"${zstd.bin}/bin/libzstd.dll"
"${windows.mingw_w64_pthreads}/bin/libwinpthread-1.dll"
"${windows.mcfgthreads}/bin/libmcfgthread-1.dll"
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libgcc_s_seh-1.dll"
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libstdc++-6.dll"
];
}
''
mkdir -p $out
for so in $deps
do
cp $so $out/
done
cp ${cronosd}/bin/${cronosd.meta.mainProgram} $out/
''
cp ${cronosd}/bin/${cronosd.meta.mainProgram} $out/
''
4 changes: 1 addition & 3 deletions nix/cosmovisor.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{ buildGoModule
, fetchFromGitHub
}:
{ buildGoModule, fetchFromGitHub }:

let
version = "1.5.0";
Expand Down
Loading

0 comments on commit f1acbc9

Please sign in to comment.