Skip to content

Commit

Permalink
Problem: rustc in nixpkgs is too old (#1316)
Browse files Browse the repository at this point in the history
Solution:
- update nixpkgs to release-23.11

re-enable dapp

update pystarport

fix chain-main

fix chain-main

update chain-main

fix build

fix win bundle

fix release.sh on apple silicon

try our luck on mac

Problem: cross-compiling macos binaries is problematic in recent nixpkgs

Solution:
- use the github macos-14 arm mac runner to build arm mac binaries
  • Loading branch information
yihuang authored Feb 19, 2024
1 parent 114f5a3 commit 7c976f4
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 203 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:
jobs:
golangci:
name: Run golangci-lint
runs-on: ubuntu-latest
runs-on: macos-latest
timeout-minutes: 40
steps:
- uses: actions/setup-go@v3
Expand Down
9 changes: 5 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ buildGoApplication rec {
subPackages = [ "cmd/cronosd" ];
buildFlags = lib.optionalString coverage "-cover";
CGO_ENABLED = "1";
CGO_LDFLAGS =
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";
else "-lrocksdb -pthread -lstdc++ -ldl"
);

postFixup = lib.optionalString stdenv.isDarwin ''
${stdenv.cc.targetPrefix}install_name_tool -change "@rpath/librocksdb.8.dylib" "${rocksdb}/lib/librocksdb.dylib" $out/bin/cronosd
postFixup = lib.optionalString (stdenv.isDarwin && rocksdb != null) ''
${stdenv.cc.bintools.targetPrefix}install_name_tool -change "@rpath/librocksdb.8.dylib" "${rocksdb}/lib/librocksdb.dylib" $out/bin/cronosd
'';

doCheck = false;
Expand Down
8 changes: 4 additions & 4 deletions flake.lock

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

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";
nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
flake-utils.url = "github:numtide/flake-utils";
nix-bundle-exe = {
url = "github:3noch/nix-bundle-exe";
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/crypto-org-chain/cronos/v2

go 1.20
go 1.21

require (
cosmossdk.io/api v0.3.1
Expand Down
141 changes: 102 additions & 39 deletions integration_tests/poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions integration_tests/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pytest-github-actions-annotate-failures = "^0.1.1"
flake8 = "^4.0.1"
black = "^22.3.0"
flake8-black = "^0.3.2"
flake8-isort = "^4.1.1"
flake8-isort = "^6.1.1"
pep8-naming = "^0.11.1"
protobuf = "^3.13.0"
grpcio = "^1.53.2"
Expand All @@ -20,7 +20,7 @@ python-dateutil = "^2.8.1"
web3 = "^6.0.0b6"
eth-bloom = "^1.0.4"
python-dotenv = "^0.19.2"
pystarport = { git = "https://github.com/crypto-com/pystarport.git", branch = "main", rev = "39ecbd29fcdd50cb3015524c13755fda05bdf23d" }
pystarport = { git = "https://github.com/crypto-com/pystarport.git", branch = "main", rev = "403b845" }
websockets = "^10.3"
toml = "^0.10.2"
pysha3 = "^1.0.2"
Expand All @@ -33,5 +33,5 @@ flaky = "^3.7.0"
[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
1 change: 0 additions & 1 deletion integration_tests/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pkgs.mkShell {
(pkgs.callPackage ../. { coverage = true; }) # cronosd
pkgs.start-scripts
pkgs.go-ethereum
pkgs.gorc
pkgs.cosmovisor
pkgs.poetry
pkgs.nodejs
Expand Down
11 changes: 0 additions & 11 deletions nix/build_overlay.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
# some basic overlays nessesary for the build
final: super: {
# include the fix: https://github.com/NixOS/nixpkgs/pull/211515
zstd = final.callPackage ./zstd.nix {
cmake = final.buildPackages.cmakeMinimal;
};
rocksdb = final.callPackage ./rocksdb.nix { };
go_1_20 = super.go_1_20.overrideAttrs (prev: rec {
version = "1.20.4";
src = final.fetchurl {
url = "https://go.dev/dl/go${version}.src.tar.gz";
hash = "sha256-nzSs4Sh2S3o6SyOLgFhWzBshhDBN+eVpCCWwcQ9CAtY=";
};
});
}
6 changes: 3 additions & 3 deletions nix/bundle-win-exe.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ runCommand "tarball-${cronosd.name}"
"${zlib}/bin/zlib1.dll"
"${zstd.bin}/bin/libzstd.dll"
"${windows.mingw_w64_pthreads}/bin/libwinpthread-1.dll"
"${windows.mcfgthreads}/bin/mcfgthread-12.dll"
"${stdenv.cc.cc}/x86_64-w64-mingw32/lib/libgcc_s_seh-1.dll"
"${stdenv.cc.cc}/x86_64-w64-mingw32/lib/libstdc++-6.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
Expand Down
7 changes: 4 additions & 3 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import sources.nixpkgs {
flake-compat = import sources.flake-compat;
chain-maind = pkgs.callPackage sources.chain-main { rocksdb = null; };
}) # update to a version that supports eip-1559
(import "${sources.poetry2nix}/overlay.nix")
(import "${sources.gomod2nix}/overlay.nix")
(pkgs: _:
import ./scripts.nix {
Expand Down Expand Up @@ -43,11 +44,11 @@ import sources.nixpkgs {
})
(_: pkgs: { test-env = pkgs.callPackage ./testenv.nix { }; })
(_: pkgs: {
cosmovisor = pkgs.buildGo118Module rec {
cosmovisor = pkgs.buildGo120Module rec {
name = "cosmovisor";
src = sources.cosmos-sdk + "/cosmovisor";
subPackages = [ "./cmd/cosmovisor" ];
vendorSha256 = "sha256-OAXWrwpartjgSP7oeNvDJ7cTR9lyYVNhEM8HUnv3acE=";
vendorHash = "sha256-OAXWrwpartjgSP7oeNvDJ7cTR9lyYVNhEM8HUnv3acE=";
doCheck = false;
};
})
Expand All @@ -56,7 +57,7 @@ import sources.nixpkgs {
name = "rly";
src = sources.relayer;
subPackages = [ "." ];
vendorSha256 = "sha256-5s5URiAZk59mOfZdUcqYAB/IvzFuBiQH5jDBuh6huTE=";
vendorHash = "sha256-5s5URiAZk59mOfZdUcqYAB/IvzFuBiQH5jDBuh6huTE=";
doCheck = false;
GOWORK = "off";
postInstall = ''
Expand Down
2 changes: 1 addition & 1 deletion nix/go-ethereum.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ buildGoModule rec {
sha256 = "sha256-mZ11xan3MGgaUORbiQczKrXSrxzjvQMhZbpHnEal11Y=";
};

vendorSha256 = "sha256-rjSGR2ie5sFK2OOo4HUZ6+hrDlQuUDtyTKn0sh8jFBY=";
vendorHash = "sha256-rjSGR2ie5sFK2OOo4HUZ6+hrDlQuUDtyTKn0sh8jFBY=";

doCheck = false;

Expand Down
26 changes: 19 additions & 7 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"homepage": "https://crypto.org",
"owner": "crypto-org-chain",
"repo": "chain-main",
"rev": "02455a4eafa8f2f6e4bd4aa9886904cfd3d518aa",
"sha256": "0ndlld82xw5004ma97ap6z6vhfsbkcma8yhvw891l3bf98rfllgk",
"rev": "04e8e094b7d51a8cf92b74c789394b7b34987b10",
"sha256": "1yqd2i8dwphjhdsvl3v7l8gvrjjl6i6pj4nq58lwcf3s6nhwy6d5",
"type": "tarball",
"url": "https://github.com/crypto-org-chain/chain-main/archive/02455a4eafa8f2f6e4bd4aa9886904cfd3d518aa.tar.gz",
"url": "https://github.com/crypto-org-chain/chain-main/archive/04e8e094b7d51a8cf92b74c789394b7b34987b10.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"cosmos-sdk": {
Expand Down Expand Up @@ -97,15 +97,27 @@
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "master",
"branch": "release-23.11",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "90aa73fc8e1550b16d1ebdc436e48d9951f7989b",
"sha256": "0jh4npbcqjlszhnaz5mkziv5g1p5ig6wqp68yjxkjllsc7vhsrw6",
"rev": "0ca77ade2a34c5466be6d54f1267507860c95da8",
"sha256": "11q88xx5njl31h3qrc213qx43yi9fqlfrbfwv2h5dgamgbpp2jk9",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/0ca77ade2a34c5466be6d54f1267507860c95da8.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"poetry2nix": {
"branch": "master",
"description": "Convert poetry projects to nix automagically [maintainer=@adisbladis] ",
"homepage": "",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "4eb2ac54029af42a001c9901194e9ce19cbd8a40",
"sha256": "16fi71fpywiqsya1z99kkb14dansyrmkkrb2clzs3b5qqx673wf4",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/90aa73fc8e1550b16d1ebdc436e48d9951f7989b.tar.gz",
"url": "https://github.com/nix-community/poetry2nix/archive/4eb2ac54029af42a001c9901194e9ce19cbd8a40.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"relayer": {
Expand Down
3 changes: 2 additions & 1 deletion nix/testenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ poetry2nix.mkPoetryEnv {
let
buildSystems = {
eth-bloom = [ "setuptools" ];
pystarport = [ "poetry" ];
pystarport = [ "poetry-core" ];
cprotobuf = [ "setuptools" ];
durations = [ "setuptools" ];
multitail2 = [ "setuptools" ];
pytest-github-actions-annotate-failures = [ "setuptools" ];
flake8-black = [ "setuptools" ];
flake8-isort = [ "hatchling" ];
multiaddr = [ "setuptools" ];
};
in
Expand Down
122 changes: 0 additions & 122 deletions nix/zstd.nix

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ elif [[ "$build_platform" == "aarch64-linux" ]]; then
elif [[ "$build_platform" == "x86_64-darwin" ]]; then
hosts="Darwin_x86_64,native"
elif [[ "$build_platform" == "aarch64-darwin" ]]; then
# cross compiling to x86_64-darwin from aarch64-darwin is not supported
# see: https://github.com/NixOS/nixpkgs/issues/180771
hosts="Darwin_arm64,native"
else
echo "don't support build platform: $build_platform"
Expand Down

0 comments on commit 7c976f4

Please sign in to comment.