Skip to content

Commit 43f351d

Browse files
authored
Merge pull request #2 from joncinque/agave
Update to Agave v2.1 / Anchor v0.30.1
2 parents 52dbde3 + 8a74b49 commit 43f351d

File tree

9 files changed

+121
-100
lines changed

9 files changed

+121
-100
lines changed

anchor-cli.nix

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55
, libgcc
66
, pkg-config
77
, protobuf
8-
, rustPlatform
8+
, makeRustPlatform
99
, makeWrapper
1010
, solana-platform-tools
11+
, rust-bin
1112
, udev
1213
}:
14+
let
15+
# Anchor does not declare a rust-toolchain, so we have to do it here -- the
16+
# old dependency on the `time` crate doesn't support Rust versions >= 1.80.
17+
rustPlatform = makeRustPlatform {
18+
cargo = rust-bin.stable."1.79.0".default;
19+
rustc = rust-bin.stable."1.79.0".default;
20+
};
21+
in
1322
rustPlatform.buildRustPackage rec {
1423
pname = "anchor-cli";
15-
version = "0.29.0";
24+
version = "0.30.1";
1625

1726
doCheck = false;
1827

@@ -28,21 +37,20 @@ rustPlatform.buildRustPackage rec {
2837
owner = "coral-xyz";
2938
repo = "anchor";
3039
rev = "v${version}";
31-
hash = "sha256-mftge1idALb4vwyF8wGo6qLmrnvCBK3l+Iw7txCyhDc=";
40+
hash = "sha256-3fLYTJDVCJdi6o0Zd+hb9jcPDKm4M4NzpZ8EUVW/GVw=";
3241
};
3342

3443
cargoLock = {
3544
lockFile = "${src.outPath}/Cargo.lock";
3645
allowBuiltinFetchGit = true;
3746
};
3847

39-
buildAndTestSubdir = "cli";
40-
4148
patches = [
42-
# Set default architecture to sbf instead of bpf
4349
./anchor-cli.patch
4450
];
4551

52+
buildAndTestSubdir = "cli";
53+
4654
# Ensure anchor has access to Solana's cargo and rust binaries
4755
postInstall = ''
4856
rust=${solana-platform-tools}/bin/sdk/sbf/dependencies/platform-tools/rust/bin

anchor-cli.patch

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,45 @@
1-
diff --git a/cli/src/lib.rs b/cli/src/lib.rs
2-
index 4fdf34b0..0ef43c9e 100644
3-
--- a/cli/src/lib.rs
4-
+++ b/cli/src/lib.rs
5-
@@ -129,7 +129,7 @@ pub enum Command {
6-
#[clap(long)]
7-
no_docs: bool,
8-
/// Architecture to use when building the program
9-
- #[clap(value_enum, long, default_value = "bpf")]
10-
+ #[clap(value_enum, long, default_value = "sbf")]
11-
arch: ProgramArch,
12-
},
13-
/// Expands macros (wrapper around cargo expand)
14-
@@ -166,7 +166,7 @@ pub enum Command {
15-
#[clap(value_enum, short, long, default_value = "none")]
16-
bootstrap: BootstrapMode,
17-
/// Architecture to use when building the program
18-
- #[clap(value_enum, long, default_value = "bpf")]
19-
+ #[clap(value_enum, long, default_value = "sbf")]
20-
arch: ProgramArch,
21-
/// Environment variables to pass into the docker container
22-
#[clap(short, long, required = false)]
23-
@@ -199,7 +199,7 @@ pub enum Command {
24-
#[clap(long)]
25-
skip_build: bool,
26-
/// Architecture to use when building the program
27-
- #[clap(value_enum, long, default_value = "bpf")]
28-
+ #[clap(value_enum, long, default_value = "sbf")]
29-
arch: ProgramArch,
30-
/// Flag to keep the local validator running after tests
31-
/// to be able to check the transactions.
32-
@@ -297,7 +297,7 @@ pub enum Command {
33-
#[clap(long)]
34-
skip_build: bool,
35-
/// Architecture to use when building the program
36-
- #[clap(value_enum, long, default_value = "bpf")]
37-
+ #[clap(value_enum, long, default_value = "sbf")]
38-
arch: ProgramArch,
39-
},
40-
/// Keypair commands.
41-
@@ -320,7 +320,7 @@ pub enum Command {
42-
#[clap(long)]
43-
skip_lint: bool,
44-
/// Architecture to use when building the program
45-
- #[clap(value_enum, long, default_value = "bpf")]
46-
+ #[clap(value_enum, long, default_value = "sbf")]
47-
arch: ProgramArch,
48-
/// Environment variables to pass into the docker container
49-
#[clap(short, long, required = false)]
1+
diff --git a/idl/src/build.rs b/idl/src/build.rs
2+
index 96dc3db2..1b098718 100644
3+
--- a/idl/src/build.rs
4+
+++ b/idl/src/build.rs
5+
@@ -60,16 +60,8 @@ pub fn build_idl(
6+
7+
/// Build IDL.
8+
fn build(program_path: &Path, resolution: bool, skip_lint: bool, no_docs: bool) -> Result<Idl> {
9+
- // `nightly` toolchain is currently required for building the IDL.
10+
- let toolchain = std::env::var("RUSTUP_TOOLCHAIN")
11+
- .map(|toolchain| format!("+{}", toolchain))
12+
- .unwrap_or_else(|_| "+nightly".to_string());
13+
-
14+
- install_toolchain_if_needed(&toolchain)?;
15+
-
16+
let output = Command::new("cargo")
17+
.args([
18+
- &toolchain,
19+
"test",
20+
"__anchor_private_print_idl",
21+
"--features",
22+
@@ -202,23 +194,6 @@ fn build(program_path: &Path, resolution: bool, skip_lint: bool, no_docs: bool)
23+
idl.ok_or_else(|| anyhow!("IDL doesn't exist"))
24+
}
25+
26+
-/// Install the given toolchain if it's not already installed.
27+
-fn install_toolchain_if_needed(toolchain: &str) -> Result<()> {
28+
- let is_installed = Command::new("cargo")
29+
- .arg(toolchain)
30+
- .output()?
31+
- .status
32+
- .success();
33+
- if !is_installed {
34+
- Command::new("rustup")
35+
- .args(["toolchain", "install", toolchain.trim_start_matches('+')])
36+
- .spawn()?
37+
- .wait()?;
38+
- }
39+
-
40+
- Ok(())
41+
-}
42+
-
43+
/// Convert paths to name if there are no conflicts.
44+
fn convert_module_paths(idl: Idl) -> Idl {
45+
let idl = serde_json::to_string(&idl).unwrap();

cargo-build-sbf.patch

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
diff --git a/sdk/cargo-build-sbf/src/main.rs b/sdk/cargo-build-sbf/src/main.rs
2-
index 1a9e4e1b62..3cb0f2af4f 100644
2+
index 03bfce2cab..0485721b4a 100644
33
--- a/sdk/cargo-build-sbf/src/main.rs
44
+++ b/sdk/cargo-build-sbf/src/main.rs
5-
@@ -4,7 +4,6 @@ use {
5+
@@ -5,7 +5,6 @@ use {
66
itertools::Itertools,
77
log::*,
88
regex::Regex,
99
- solana_download_utils::download_file,
1010
solana_sdk::signature::{write_keypair_file, Keypair},
1111
std::{
1212
borrow::Cow,
13-
@@ -233,95 +232,12 @@ fn make_platform_tools_path_for_version(package: &str, version: &str) -> PathBuf
13+
@@ -255,96 +254,13 @@ fn make_platform_tools_path_for_version(package: &str, version: &str) -> PathBuf
1414

1515
// Check whether a package is installed and install it if missing.
1616
fn install_if_missing(
1717
- config: &Config,
1818
- package: &str,
1919
- url: &str,
2020
- download_file_name: &str,
21+
- platform_tools_version: &str,
2122
- target_path: &Path,
2223
+ _config: &Config,
2324
+ _package: &str,
2425
+ _url: &str,
2526
+ _download_file_name: &str,
27+
+ _platform_tools_version: &str,
2628
+ _target_path: &Path,
2729
) -> Result<(), String> {
2830
- if config.force_tools_install {
@@ -69,7 +71,7 @@ index 1a9e4e1b62..3cb0f2af4f 100644
6971
- fs::create_dir_all(target_path).map_err(|err| err.to_string())?;
7072
- let mut url = String::from(url);
7173
- url.push('/');
72-
- url.push_str(config.platform_tools_version);
74+
- url.push_str(platform_tools_version);
7375
- url.push('/');
7476
- url.push_str(download_file_name);
7577
- let download_file_path = target_path.join(download_file_name);
@@ -111,15 +113,15 @@ index 1a9e4e1b62..3cb0f2af4f 100644
111113
Ok(())
112114
}
113115

114-
@@ -634,7 +550,6 @@ fn build_solana_package(
116+
@@ -680,7 +596,6 @@ fn build_solana_package(
115117
error!("Failed to install platform-tools: {}", err);
116118
exit(1);
117119
});
118120
- link_solana_toolchain(config);
119121

120122
let llvm_bin = config
121123
.sbf_sdk
122-
@@ -692,7 +607,6 @@ fn build_solana_package(
124+
@@ -738,7 +653,6 @@ fn build_solana_package(
123125

124126
let cargo_build = PathBuf::from("cargo");
125127
let mut cargo_build_args = vec![

criterion.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ criterion.overrideAttrs rec {
1515
fetchSubmodules = true;
1616
};
1717

18-
# Remove attrs for v2.4
18+
# Remove attrs for v2.4.1
1919
# https://github.com/NixOS/nixpkgs/commit/bff379e9ed908e737009038c24d548ba17e81ee2
2020
nativeBuildInputs = [ cmake pkg-config ];
2121
checkTarget = "criterion_tests test";
2222
cmakeFlags = [ "-DCTESTS=ON" ];
2323
# Disable this phase
2424
postPatch = "";
25+
# Remove attrs for v2.4.2
26+
# https://github.com/NixOS/nixpkgs/commit/558c5c6559730420356ee6703c0c351b2f97d3fb
27+
# Disable this phase
28+
prePatch = "";
2529
}

nix/sources.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
{
22
"nixpkgs": {
3-
"branch": "release-23.11",
3+
"branch": "release-24.11",
44
"description": "Nix Packages collection & NixOS",
55
"homepage": "",
66
"owner": "nixos",
77
"repo": "nixpkgs",
8-
"rev": "08f49cc8d224dbef144d848cea2da3e01d9f2c65",
9-
"sha256": "0sf0iya9bnw2j4mhw7msgaz6j06j333hirn3q810f00qayy97047",
8+
"rev": "c387cc8d7f36f39c664ec4ebd31bbd599afee63a",
9+
"sha256": "0mjdqjwax51h93kibn533wrl12zc5i81aa2sw1hw072690w1lcqr",
1010
"type": "tarball",
11-
"url": "https://github.com/nixos/nixpkgs/archive/08f49cc8d224dbef144d848cea2da3e01d9f2c65.tar.gz",
11+
"url": "https://github.com/nixos/nixpkgs/archive/c387cc8d7f36f39c664ec4ebd31bbd599afee63a.tar.gz",
12+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+
},
14+
"rust_overlay": {
15+
"branch": "master",
16+
"description": "Pure and reproducible nix overlay of binary distributed rust toolchains",
17+
"homepage": "",
18+
"owner": "oxalica",
19+
"repo": "rust-overlay",
20+
"rev": "dd236609a6c272d00ceaa042b1a81a31968e7f4d",
21+
"sha256": "14sr0bhqjn7yg6gkn6cxxmkb5l0ncd6n7rxx41d07wfv7ycn325f",
22+
"type": "tarball",
23+
"url": "https://github.com/oxalica/rust-overlay/archive/dd236609a6c272d00ceaa042b1a81a31968e7f4d.tar.gz",
1224
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
1325
}
1426
}

pkgs.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
}:
66
let
77
nixpkgs = sources.nixpkgs;
8+
rust_overlay = import (sources.rust_overlay);
89

910
overlays = [
1011
(self: super: {
@@ -16,6 +17,7 @@ let
1617
anchor-cli = self.callPackage (import ./anchor-cli.nix) { };
1718
}
1819
)
20+
rust_overlay
1921
];
2022
in
2123
import nixpkgs { inherit config system overlays; }

solana-cli.nix

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
, udev
1010
, protobuf
1111
, libcxx
12-
, rocksdb
12+
, rocksdb_8_11
1313
, snappy
1414
, pkg-config
1515
, makeWrapper
@@ -19,30 +19,25 @@
1919
, nix-update-script
2020
# Taken from https://github.com/solana-labs/solana/blob/master/scripts/cargo-install-all.sh#L84
2121
, solanaPkgs ? [
22+
"agave-install"
23+
"agave-install-init"
24+
"agave-ledger-tool"
25+
"agave-validator"
26+
"agave-watchtower"
27+
"cargo-build-sbf"
28+
"cargo-test-sbf"
29+
"rbpf-cli"
2230
"solana"
2331
"solana-bench-tps"
2432
"solana-faucet"
2533
"solana-gossip"
26-
"solana-install"
2734
"solana-keygen"
2835
"solana-log-analyzer"
2936
"solana-net-shaper"
30-
"rbpf-cli"
31-
"solana-validator"
32-
"solana-ledger-tool"
33-
"cargo-build-bpf"
34-
"cargo-test-bpf"
3537
"solana-dos"
36-
"solana-install-init"
3738
"solana-stake-accounts"
3839
"solana-test-validator"
3940
"solana-tokens"
40-
"solana-watchtower"
41-
"cargo-test-sbf"
42-
"cargo-build-sbf"
43-
] ++ [
44-
# XXX: Ensure `solana-genesis` is built LAST!
45-
# See https://github.com/solana-labs/solana/issues/5826
4641
"solana-genesis"
4742
]
4843
}:
@@ -62,7 +57,6 @@ rustPlatform.buildRustPackage rec {
6257
lockFile = "${src.outPath}/Cargo.lock";
6358
outputHashes = {
6459
"crossbeam-epoch-0.9.5" = "sha256-Jf0RarsgJiXiZ+ddy0vp4jQ59J9m0k3sgXhWhCdhgws=";
65-
"tokio-1.29.1" = "sha256-Z/kewMCqkPVTXdoBcSaFKG5GSQAdkdpj3mAzLLCjjGk=";
6660
};
6761
};
6862

@@ -94,9 +88,8 @@ rustPlatform.buildRustPackage rec {
9488
# wrapProgram $out/bin/tailscaled --prefix PATH : ${pkgs.lib.makeBinPath
9589

9690
postInstall = ''
97-
mkdir -p $out/bin/sdk/bpf
98-
cp -a ./sdk/bpf/* $out/bin/sdk/bpf/
99-
cp -a ./sdk/sbf $out/bin/sdk/sbf
91+
mkdir -p $out/bin/sdk/sbf
92+
cp -a ./sdk/sbf/* $out/bin/sdk/sbf/
10093
10194
rust=${solana-platform-tools}/bin/sdk/sbf/dependencies/platform-tools/rust/bin
10295
sbfsdkdir=${solana-platform-tools}/bin/sdk/sbf
@@ -107,8 +100,8 @@ rustPlatform.buildRustPackage rec {
107100

108101
# Used by build.rs in the rocksdb-sys crate. If we don't set these, it would
109102
# try to build RocksDB from source.
110-
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
111-
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
103+
ROCKSDB_LIB_DIR = "${rocksdb_8_11}/lib";
104+
ROCKSDB_INCLUDE_DIR = "${rocksdb_8_11}/include";
112105

113106
# Require this on darwin otherwise the compiler starts rambling about missing
114107
# cmath functions

0 commit comments

Comments
 (0)