Last active
September 24, 2023 22:52
-
-
Save bergkvist/d3ecd2d2f738fdbf63c83a48e4624f03 to your computer and use it in GitHub Desktop.
eth2spec 1.4.0-beta.2 environment (https://github.com/ethereum/consensus-specs) with jupyterlab in nix.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To get started: | |
# 1. Copy this into a file called `shell.nix` locally | |
# 2. Install nix (https://nix.dev/tutorials/install-nix) | |
# 3. Type nix-shell --run "jupyter lab" | |
# 4. Create a new Python notebook by clicking on the button in the browser UI | |
# 5. Put `import eth2spec.capella` into a cell and press Shift+Enter | |
# 6. Put `eth2spec.capella.mainnet.BeaconBlock()` into the next cell and press Shift+Enter | |
{ pkgs ? import (fetchTarball { | |
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.05.tar.gz"; | |
sha256 = "10wn0l08j9lgqcw8177nh2ljrnxdrpri7bp0g7nvrsn9rkawvlbf"; | |
}) {} | |
, python ? pkgs.python311 | |
}: | |
let | |
remove-maturin-metadata-from-cargotoml = pkgs.writeText "remove-maturin-metadata-from-cargotoml.patch" '' | |
diff --git a/Cargo.toml b/Cargo.toml | |
index f150341..79ab9ab 100644 | |
--- a/Cargo.toml | |
+++ b/Cargo.toml | |
@@ -5,19 +5,6 @@ edition = "2018" | |
authors = ["chihchengliang@gmail.com"] | |
readme = "README.md" | |
-[package.metadata.maturin] | |
-classifier = [ | |
- "Development Status :: 3 - Alpha", | |
- "Intended Audience :: Developers", | |
- "License :: OSI Approved :: MIT License", | |
- "Natural Language :: English", | |
- "Programming Language :: Python :: 3.7", | |
-] | |
-maintainer = "Chih-Cheng Liang" | |
-maintainer-email = "chihchengliang@gmail.com" | |
-requires-python = ">=3.7" | |
-project-url = { Source = "https://github.com/ChihChengLiang/milagro_bls_binding/" } | |
- | |
[lib] | |
name = "milagro_bls_binding" | |
crate-type = ["cdylib"] | |
''; | |
milagro-bls-binding-cargolock = pkgs.writeText "Cargo.lock" '' | |
# This file is automatically @generated by Cargo. | |
# It is not intended for manual editing. | |
version = 3 | |
[[package]] | |
name = "amcl" | |
version = "0.3.0" | |
source = "git+https://github.com/sigp/milagro_bls?tag=v1.5.0#421aa3af8a0618a46144560389debbe7e56609db" | |
[[package]] | |
name = "autocfg" | |
version = "1.1.0" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" | |
[[package]] | |
name = "bitflags" | |
version = "1.3.2" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" | |
[[package]] | |
name = "cfg-if" | |
version = "1.0.0" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" | |
[[package]] | |
name = "getrandom" | |
version = "0.2.10" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" | |
dependencies = [ | |
"cfg-if", | |
"libc", | |
"wasi", | |
] | |
[[package]] | |
name = "hex" | |
version = "0.4.3" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" | |
[[package]] | |
name = "indoc" | |
version = "1.0.9" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" | |
[[package]] | |
name = "lazy_static" | |
version = "1.4.0" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" | |
[[package]] | |
name = "libc" | |
version = "0.2.148" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" | |
[[package]] | |
name = "lock_api" | |
version = "0.4.10" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" | |
dependencies = [ | |
"autocfg", | |
"scopeguard", | |
] | |
[[package]] | |
name = "milagro-bls-binding" | |
version = "1.9.0" | |
dependencies = [ | |
"milagro_bls", | |
"pyo3", | |
"rand", | |
] | |
[[package]] | |
name = "milagro_bls" | |
version = "1.5.0" | |
source = "git+https://github.com/sigp/milagro_bls?tag=v1.5.0#421aa3af8a0618a46144560389debbe7e56609db" | |
dependencies = [ | |
"amcl", | |
"hex", | |
"lazy_static", | |
"rand", | |
"zeroize", | |
] | |
[[package]] | |
name = "once_cell" | |
version = "1.18.0" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" | |
[[package]] | |
name = "parking_lot" | |
version = "0.12.1" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" | |
dependencies = [ | |
"lock_api", | |
"parking_lot_core", | |
] | |
[[package]] | |
name = "parking_lot_core" | |
version = "0.9.8" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" | |
dependencies = [ | |
"cfg-if", | |
"libc", | |
"redox_syscall", | |
"smallvec", | |
"windows-targets", | |
] | |
[[package]] | |
name = "ppv-lite86" | |
version = "0.2.17" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" | |
[[package]] | |
name = "proc-macro2" | |
version = "1.0.67" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" | |
dependencies = [ | |
"unicode-ident", | |
] | |
[[package]] | |
name = "pyo3" | |
version = "0.16.6" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "0220c44442c9b239dd4357aa856ac468a4f5e1f0df19ddb89b2522952eb4c6ca" | |
dependencies = [ | |
"cfg-if", | |
"indoc", | |
"libc", | |
"parking_lot", | |
"pyo3-build-config", | |
"pyo3-ffi", | |
"pyo3-macros", | |
"unindent", | |
] | |
[[package]] | |
name = "pyo3-build-config" | |
version = "0.16.6" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "9c819d397859445928609d0ec5afc2da5204e0d0f73d6bf9e153b04e83c9cdc2" | |
dependencies = [ | |
"once_cell", | |
"target-lexicon", | |
] | |
[[package]] | |
name = "pyo3-ffi" | |
version = "0.16.6" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "ca882703ab55f54702d7bfe1189b41b0af10272389f04cae38fe4cd56c65f75f" | |
dependencies = [ | |
"libc", | |
"pyo3-build-config", | |
] | |
[[package]] | |
name = "pyo3-macros" | |
version = "0.16.6" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "568749402955ad7be7bad9a09b8593851cd36e549ac90bfd44079cea500f3f21" | |
dependencies = [ | |
"proc-macro2", | |
"pyo3-macros-backend", | |
"quote", | |
"syn", | |
] | |
[[package]] | |
name = "pyo3-macros-backend" | |
version = "0.16.6" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "611f64e82d98f447787e82b8e7b0ebc681e1eb78fc1252668b2c605ffb4e1eb8" | |
dependencies = [ | |
"proc-macro2", | |
"quote", | |
"syn", | |
] | |
[[package]] | |
name = "quote" | |
version = "1.0.33" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" | |
dependencies = [ | |
"proc-macro2", | |
] | |
[[package]] | |
name = "rand" | |
version = "0.8.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" | |
dependencies = [ | |
"libc", | |
"rand_chacha", | |
"rand_core", | |
] | |
[[package]] | |
name = "rand_chacha" | |
version = "0.3.1" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" | |
dependencies = [ | |
"ppv-lite86", | |
"rand_core", | |
] | |
[[package]] | |
name = "rand_core" | |
version = "0.6.4" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" | |
dependencies = [ | |
"getrandom", | |
] | |
[[package]] | |
name = "redox_syscall" | |
version = "0.3.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" | |
dependencies = [ | |
"bitflags", | |
] | |
[[package]] | |
name = "scopeguard" | |
version = "1.2.0" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" | |
[[package]] | |
name = "smallvec" | |
version = "1.11.1" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" | |
[[package]] | |
name = "syn" | |
version = "1.0.109" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" | |
dependencies = [ | |
"proc-macro2", | |
"quote", | |
"unicode-ident", | |
] | |
[[package]] | |
name = "target-lexicon" | |
version = "0.12.11" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" | |
[[package]] | |
name = "unicode-ident" | |
version = "1.0.12" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" | |
[[package]] | |
name = "unindent" | |
version = "0.1.11" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" | |
[[package]] | |
name = "wasi" | |
version = "0.11.0+wasi-snapshot-preview1" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" | |
[[package]] | |
name = "windows-targets" | |
version = "0.48.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" | |
dependencies = [ | |
"windows_aarch64_gnullvm", | |
"windows_aarch64_msvc", | |
"windows_i686_gnu", | |
"windows_i686_msvc", | |
"windows_x86_64_gnu", | |
"windows_x86_64_gnullvm", | |
"windows_x86_64_msvc", | |
] | |
[[package]] | |
name = "windows_aarch64_gnullvm" | |
version = "0.48.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" | |
[[package]] | |
name = "windows_aarch64_msvc" | |
version = "0.48.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" | |
[[package]] | |
name = "windows_i686_gnu" | |
version = "0.48.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" | |
[[package]] | |
name = "windows_i686_msvc" | |
version = "0.48.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" | |
[[package]] | |
name = "windows_x86_64_gnu" | |
version = "0.48.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" | |
[[package]] | |
name = "windows_x86_64_gnullvm" | |
version = "0.48.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" | |
[[package]] | |
name = "windows_x86_64_msvc" | |
version = "0.48.5" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" | |
[[package]] | |
name = "zeroize" | |
version = "1.6.0" | |
source = "registry+https://github.com/rust-lang/crates.io-index" | |
checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" | |
''; | |
python-packages = rec { | |
lru-dict = python.pkgs.buildPythonPackage rec { | |
pname = "lru-dict"; | |
version = "1.2.0"; | |
src = python.pkgs.fetchPypi { | |
inherit pname version; | |
sha256 = "sha256-E8VngvGdaN302NsBcAQRkoWWFlFMcGsSbQ3y7HKhG9c="; | |
}; | |
}; | |
pycryptodome = python.pkgs.buildPythonPackage rec { | |
pname = "pycryptodome"; | |
version = "3.15.0"; | |
src = python.pkgs.fetchPypi { | |
inherit pname version; | |
sha256 = "sha256-kTXd2tUEWSvMGLDS2VzobDpeqH7GRH7yXP7eoS1gGLg="; | |
}; | |
}; | |
merlin-transcripts = python.pkgs.buildPythonPackage rec { | |
pname = "merlin_transcripts"; | |
version = "0.1.1"; | |
format = "pyproject"; | |
src = python.pkgs.fetchPypi { | |
inherit pname version; | |
sha256 = "sha256-3cTaPMPCCdarYvqLXow7xgrYbosunF+faH9DIMoz8UU="; | |
}; | |
propagatedBuildInputs = [ python.pkgs.poetry-core ]; | |
}; | |
curdleproofs = python.pkgs.buildPythonPackage rec { | |
pname = "curdleproofs"; | |
version = "0.1.1"; | |
format = "pyproject"; | |
src = python.pkgs.fetchPypi { | |
inherit pname version; | |
sha256 = "sha256-hWVTWczWezqT+iFSvPwZ39TLTQ9LHvcxgd/TS69B/UI="; | |
}; | |
propagatedBuildInputs = [ | |
python.pkgs.poetry-core | |
merlin-transcripts | |
py-arkworks-bls12381 | |
]; | |
}; | |
py-arkworks-bls12381 = python.pkgs.buildPythonPackage rec { | |
pname = "py_arkworks_bls12381"; | |
version = "0.3.4"; | |
format = "pyproject"; | |
src = python.pkgs.fetchPypi { | |
inherit pname version; | |
sha256 = "sha256-k6htJLCwdyLJRJzvUj6XfCAY7HZzrM+sJTNGlPQPOEg="; | |
}; | |
cargoDeps = pkgs.rustPlatform.fetchCargoTarball { | |
inherit src; | |
name = "${pname}-${version}"; | |
sha256 = "sha256-3Tn7JwmgV4v9w806NH0dCXesM9QxUUVj8cvJ91vI+nE="; | |
}; | |
buildInputs = [ pkgs.libiconv ]; | |
nativeBuildInputs = [ | |
pkgs.rustPlatform.cargoSetupHook | |
pkgs.rustPlatform.maturinBuildHook | |
]; | |
}; | |
marko = python.pkgs.buildPythonPackage rec { | |
pname = "marko"; | |
version = "1.0.2"; | |
format = "pyproject"; | |
src = python.pkgs.fetchPypi { | |
inherit pname version; | |
sha256 = "sha256-vfLkbeVvAi85MPsX977ekKi8LqJ73Gioh6Ak4eVFKzc="; | |
}; | |
nativeBuildInputs = [ | |
python.pkgs.pdm-backend | |
python.pkgs.pdm-pep517 | |
]; | |
}; | |
trie = python.pkgs.buildPythonPackage rec { | |
pname = "trie"; | |
version = "2.0.2"; | |
src = python.pkgs.fetchPypi { | |
inherit pname version; | |
sha256 = "sha256-i/xrgpebfKpvAgqJyRQsdSLwF3iCQEh9HJQbCtgucTI="; | |
}; | |
propagatedBuildInputs = [ | |
python.pkgs.eth-hash | |
python.pkgs.eth-utils | |
python.pkgs.hexbytes | |
python.pkgs.rlp | |
python.pkgs.sortedcontainers | |
]; | |
}; | |
remerkleable = python.pkgs.buildPythonPackage rec { | |
pname = "remerkleable"; | |
version = "0.1.27"; | |
doCheck = false; | |
src = python.pkgs.fetchPypi { | |
inherit pname version; | |
sha256 = "sha256-dPqiKGAbRyTpCLoagLqaiER4NMU/6qe+FZlfTeEV/LM="; | |
}; | |
}; | |
milagro-bls-binding = python.pkgs.buildPythonPackage rec { | |
pname = "milagro_bls_binding"; | |
version = "1.9.0"; | |
format = "pyproject"; | |
src = python.pkgs.fetchPypi { | |
inherit pname version; | |
sha256 = "sha256-Q/tBszWypA7iHyaYxq4n7YOSH19hCUQ3BfeTx31LbW4="; | |
}; | |
patches = [ | |
(pkgs.runCommand "add-cargolock.patch" { buildInputs = [pkgs.git]; } '' | |
cp "${milagro-bls-binding-cargolock}" Cargo.lock | |
git init && git add Cargo.lock | |
git diff --cached > $out | |
'') | |
(remove-maturin-metadata-from-cargotoml) | |
]; | |
cargoDeps = pkgs.rustPlatform.importCargoLock { | |
lockFile = milagro-bls-binding-cargolock; | |
outputHashes = { | |
"amcl-0.3.0" = "sha256-aadWn2xi4jtyXoxr5UoigKFV5bDEATb65sqwgvEt/r8="; | |
}; | |
}; | |
buildInputs = [ pkgs.libiconv ]; | |
nativeBuildInputs = [ | |
pkgs.rustPlatform.cargoSetupHook | |
pkgs.rustPlatform.maturinBuildHook | |
]; | |
}; | |
eth2spec = python.pkgs.buildPythonPackage rec { | |
pname = "eth2spec"; | |
version = "1.4.0-beta.2"; | |
src = fetchTarball { | |
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/v${version}.tar.gz"; | |
sha256 = "0hqpa1l8blb70fcbxpyprlkv90fz9pkrjj48l432ra8l0x4wl1r7"; | |
}; | |
propagatedBuildInputs = [ | |
python.pkgs.setuptools | |
python.pkgs.eth-utils | |
python.pkgs.eth-typing | |
python.pkgs.py-ecc | |
python.pkgs.ruamel-yaml | |
milagro-bls-binding | |
remerkleable | |
trie | |
marko | |
py-arkworks-bls12381 | |
curdleproofs | |
pycryptodome | |
lru-dict | |
]; | |
}; | |
}; | |
in | |
pkgs.mkShell { | |
buildInputs = [ | |
(python.withPackages(ps: [ | |
python-packages.eth2spec | |
ps.jupyterlab | |
])) | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment