cardano

August 15, 2018

看 [cardano 1.3.0] 吧, 这里不要看了

资料

[cardano 资料](cardano 资料)

install

这里

取代码

git clone https://github.com/input-output-hk/cardano-sl.git
cd cardano-sl
git checkout master

装 nix curl https://nixos.org/nix/install | sh

加入信任

sudo vim /etc/nix/nix.conf
binary-caches            = https://cache.nixos.org https://hydra.iohk.io
binary-cache-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=

最后一行必须加入, 这个也是官方文档没有提到的

二进制编译(推荐)

很多时候会出现 8090 没有启动, api 无法调用的情况, 触发原因不明. 还是得用混合编译的方式

这里

nix-build -A connectScripts.mainnetWallet -o connect-to-mainnet

就可以

启动

cd cardano-sl
./connect-to-mainnet

混合编译

进入 nix-shell

cd cardano-sl
. /home/panchao/.nix-profile/etc/profile.d/nix.sh
nix-shell

这时会编译下载很多东西

运行编译脚本

./scripts/build/cardano-sl.sh

出现了报错

Going to build:  cardano-sl-networking cardano-sl-binary cardano-sl-util cardano-sl-crypto cardano-sl-core cardano-sl-db cardano-sl-lrc cardano-sl-infra cardano-sl-ssc cardano-sl-txp cardano-sl-update cardano-sl-delegation cardano-sl-block cardano-sl cardano-sl-node cardano-sl-client cardano-sl-generator cardano-sl-auxx cardano-sl-tools cardano-sl-explorer cardano-sl-wallet cardano-sl-wallet-new
Building cardano-sl-networking

stack build --ghc-options=" -Wwarn" --test --no-haddock-deps --bench --jobs=4 --no-run-tests --no-run-benchmarks --dependencies-only  cardano-sl-networking

Downloaded lts-9.1 build plan.
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading root
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading timestamp
Downloading snapshot
Downloading mirrors
Cannot update index (no local copy)
Downloading index
Updated package list downloaded
Populated index cache.
No compiler found, expected minor version match with ghc-8.0.2 (x86_64) (based on resolver setting in /home/panchao/ada/cardano-sl/stack.yaml).
To install the correct GHC into /home/panchao/.stack/programs/x86_64-linux-nix/, try running "stack setup" or use the "--install-ghc" flag. To use your system GHC installation, run "stack config set system-ghc --global true", or use the "--system-ghc" flag.

按照提示, 运行 stack setup 安装了 GHC

再次运行编译脚本

./scripts/build/cardano-sl.sh

运行到一定阶段, 出现了报错

Progress: 133/138
--  While building package aeson-1.1.2.0 using:
      /home/panchao/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/panchao/ada/cardano-sl/.stack-work/logs/aeson-1.1.2.0.log

    Configuring aeson-1.1.2.0...
    Building aeson-1.1.2.0...
    Preprocessing library aeson-1.1.2.0...
    [ 1 of 21] Compiling Data.Aeson.Types.Internal ( Data/Aeson/Types/Internal.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Data/Aeson/Types/Internal.o )
    [ 2 of 21] Compiling Data.Aeson.Types.Generic ( Data/Aeson/Types/Generic.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Data/Aeson/Types/Generic.o )
    [ 3 of 21] Compiling Data.Aeson.Parser.UnescapeFFI ( ffi/Data/Aeson/Parser/UnescapeFFI.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Data/Aeson/Parser/UnescapeFFI.o )
    [ 4 of 21] Compiling Data.Aeson.Parser.Unescape ( Data/Aeson/Parser/Unescape.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Data/Aeson/Parser/Unescape.o )
    [ 5 of 21] Compiling Data.Aeson.Parser.Internal ( Data/Aeson/Parser/Internal.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Data/Aeson/Parser/Internal.o )
    <command line>: can't load .so/.DLL for: /nix/store/zpg78y1mf0di6127q6r51kgx2q8cxsvv-glibc-2.25-49/lib/libdl.so (/nix/store/zpg78y1mf0di6127q6r51kgx2q8cxsvv-glibc-2.25-49/lib/libdl.so: symbol _dl_catch_error, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference)


--  While building package optparse-applicative-0.13.2.0 using:
      /home/panchao/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/panchao/ada/cardano-sl/.stack-work/logs/optparse-applicative-0.13.2.0.log

    Configuring optparse-applicative-0.13.2.0...
    Building optparse-applicative-0.13.2.0...
    Preprocessing library optparse-applicative-0.13.2.0...
    [ 1 of 15] Compiling Options.Applicative.Help.Pretty ( Options/Applicative/Help/Pretty.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Options/Applicative/Help/Pretty.o )
    [ 2 of 15] Compiling Options.Applicative.Help.Chunk ( Options/Applicative/Help/Chunk.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Options/Applicative/Help/Chunk.o )
    [ 3 of 15] Compiling Options.Applicative.Help.Types ( Options/Applicative/Help/Types.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Options/Applicative/Help/Types.o )
    [ 4 of 15] Compiling Options.Applicative.Types ( Options/Applicative/Types.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Options/Applicative/Types.o )
    [ 5 of 15] Compiling Options.Applicative.Internal ( Options/Applicative/Internal.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Options/Applicative/Internal.o )
    [ 6 of 15] Compiling Options.Applicative.Common ( Options/Applicative/Common.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Options/Applicative/Common.o )
    [ 7 of 15] Compiling Options.Applicative.Help.Core ( Options/Applicative/Help/Core.hs, .stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/build/Options/Applicative/Help/Core.o )
    <command line>: can't load .so/.DLL for: /nix/store/zpg78y1mf0di6127q6r51kgx2q8cxsvv-glibc-2.25-49/lib/libdl.so (/nix/store/zpg78y1mf0di6127q6r51kgx2q8cxsvv-glibc-2.25-49/lib/libdl.so: symbol _dl_catch_error, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference)

找到了这里所说的, 如果运行了stack setup 就要把 ~/.stack 删除了

依然没用

按照这里所说的操作一遍

编译出的文件在 ls .stack-work/install/x86_64-linux-nix/lts-9.1/8.0.2/bin/ 里面

启动

!注意! 必须在 /home/panchao/ada/cardano-sl 下运行脚本, 否则报找不到 lib/configuration.yaml 的错误

对 tmux 有版本要求, ubuntu16 升级 tmux

严格注意, tmux 必须要在 cardano-sl 目录启动, 否则脚本新建立的几个子窗口, 根本找不到运行的命令

实际上是开了四个窗口来运行

0

/home/panchao/cardano-sl/.stack-work/install/x86_64-linux-nix/lts-9.1/8.0.2/bin/cardano-node-simple  --db-path /home/panchao/cardano-sl/scripts/../run/node-db0   --rebuild-db   --genesis-secret 0 --listen 127.0.0.1:3000  --json-log=/home/panchao/cardano-sl/scripts/../logs/2018-05-24_215217/node0.json  --logs-prefix /home/panchao/cardano-sl/scripts/../logs/2018-05-24_215217 --log-config /home/panchao/cardano-sl/scripts/../logs/2018-05-24_215217/conf/node0.log.yaml          --system-start 1527169952 --metrics +RTS -T -RTS --ekg-server 127.0.0.1:8000 --node-id node0 --topology ./run/topology0.yaml  --update-latest-path ./run/updater0.sh  --update-with-package  --update-server 'http://127.0.0.1:10228/'  --no-ntp

1
/home/panchao/cardano-sl/.stack-work/install/x86_64-linux-nix/lts-9.1/8.0.2/bin/cardano-node-simple  --db-path /home/panchao/cardano-sl/scripts/../run/node-db1   --rebuild-db   --genesis-secret 1 --listen 127.0.0.1:3001  --json-log=/home/panchao/cardano-sl/scripts/../logs/2018-05-24_215217/node1.json  --logs-prefix /home/panchao/cardano-sl/scripts/../logs/2018-05-24_215217 --log-config /home/panchao/cardano-sl/scripts/../logs/2018-05-24_215217/conf/node1.log.yaml          --system-start 1527169952 --metrics +RTS -T
-RTS --ekg-server 127.0.0.1:8001 --node-id node1 --topology ./run/topology1.yaml  --update-latest-path ./run/updater1.sh  --update-with-package  --update-server 'http://127.0.0.1:10228/'  --no-ntp
2
/home/panchao/cardano-sl/.stack-work/install/x86_64-linux-nix/lts-9.1/8.0.2/bin/cardano-node-simple  --db-path /home/panchao/cardano-sl/scripts/../run/node-db2   --rebuild-db   --genesis-secret 2 --listen 127.0.0.1:3002  --json-log=/home/panchao/cardano-sl/scripts/../logs/2018-05-24_215217/node2.json  --logs-prefix /home/panchao/cardano-sl/scripts/../logs/2018-05-24_215217 --log-config /home/panchao/cardano-sl/scripts/../logs/2018-05-24_215217/conf/node2.log.yaml          --system-start 1527169952 --metrics +RTS -T
-RTS --ekg-server 127.0.0.1:8002 --node-id node2 --topology ./run/topology2.yaml  --update-latest-path ./run/updater2.sh  --update-with-package  --update-server 'http://127.0.0.1:10228/'  --no-ntp
3
/home/panchao/cardano-sl/.stack-work/install/x86_64-linux-nix/lts-9.1/8.0.2/bin/cardano-launcher -c /home/panchao/cardano-sl/scripts/../run/launcher-config-3.yaml
sh scripts/launch/demo-with-wallet-api.sh

api 接口

[cardano 接口](cardano 接口)

install(废弃)

https://cardanodocs.com/installation/cn

nix-build -A cardano-sl-static --cores 0 --max-jobs 2 --no-build-output --out-link master

出现报错

error: attribute 'cardano-sl-static' in selection path 'cardano-sl-static' not found

改为

nix-build -A cardano-sl-node-static --cores 0 --max-jobs 2 --no-build-output --out-link master

可以编译成功, 得到 cardano-node-simple

报什么配置文件找不到的错…

后来看到 https://github.com/input-output-hk/cardano-sl/blob/master/docs/how-to/connect-to-cluster.md

nix-build -A connectScripts.mainnetWallet -o connect-to-mainnet

运行 ./connect-to-mainnet

貌似在同步区块了

最后尝试用

nix-build -A cardano-sl-tools --cores 0 --max-jobs 2 --no-build-output --out-link master

可以把所有需要的工具都编译出来


comments powered by Disqus