From c416c7c4272ccd16c2d6bc1bc7e818988a93c7f6 Mon Sep 17 00:00:00 2001 From: Jean Date: Wed, 27 Mar 2024 14:52:33 +0100 Subject: [PATCH] fix blockchain start --- server/go.mod | 5 ++- server/go.sum | 4 +- server/scripts/setup.sh | 2 +- server/scripts/start_chain.sh | 72 +++++++++++++++++------------------ server/scripts/teardown.sh | 2 +- 5 files changed, 43 insertions(+), 42 deletions(-) diff --git a/server/go.mod b/server/go.mod index 48db24cc..df201bc9 100644 --- a/server/go.mod +++ b/server/go.mod @@ -2,8 +2,9 @@ module go.dedis.ch/hbt/server go 1.21 -// replace go.dedis.ch/dela => ../../dela -replace go.dedis.ch/purb-db => ../../purb-db +replace go.dedis.ch/dela => ../../dela + +//replace go.dedis.ch/purb-db => ../../purb-db require ( github.com/gorilla/mux v1.8.1 diff --git a/server/go.sum b/server/go.sum index e8ab12d1..56853816 100644 --- a/server/go.sum +++ b/server/go.sum @@ -131,8 +131,6 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsr github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.dedis.ch/dela v0.0.0-20231011144949-4677467c030c h1:3qMO3ewks1QptS5GJyz59HYprgBEVUjk+9BWI6vEsRc= -go.dedis.ch/dela v0.0.0-20231011144949-4677467c030c/go.mod h1:Oh/WK8JMO0POQg7nR3u436u+HwsZwPqPzDWAasgmFAU= go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs= go.dedis.ch/fixbuf v1.0.3/go.mod h1:yzJMt34Wa5xD37V5RTdmp38cz3QhMagdGoem9anUalw= go.dedis.ch/kyber/v3 v3.0.4/go.mod h1:OzvaEnPvKlyrWyp3kGXlFdp7ap1VC6RkZDTaPikqhsQ= @@ -145,6 +143,8 @@ go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRL go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4= go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo= go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4= +go.dedis.ch/purb-db v0.0.1 h1:JzZDdkd9t1wuW2X8jHXBMoakctzBkc5EW36VXev42+M= +go.dedis.ch/purb-db v0.0.1/go.mod h1:AFLiJofwHp8w9ZzG9I/Mpy7fKlsHKK13oAish6U0NuQ= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.mongodb.org/mongo-driver v1.13.2 h1:0BCe7YmG5KyiujRFA4xcU9071IFe4OFE4S3azDrsqz4= diff --git a/server/scripts/setup.sh b/server/scripts/setup.sh index 9a35ea63..601addbb 100755 --- a/server/scripts/setup.sh +++ b/server/scripts/setup.sh @@ -31,7 +31,7 @@ tmux new-window -t ${S} -n smc ./start_chain.sh -t ${L} #./start_registry.sh -t ${L} -./start_smc.sh -t ${L} +#./start_smc.sh -t ${L} #tmux send-keys -t ${S}:smc.0 "./publish_roster.sh" C-m # attach to session diff --git a/server/scripts/start_chain.sh b/server/scripts/start_chain.sh index 9fd84874..753b8d35 100755 --- a/server/scripts/start_chain.sh +++ b/server/scripts/start_chain.sh @@ -61,7 +61,9 @@ do proxy=$((PROXY + i)) echo -e "${GREEN}creating node #${i} on port ${p}${NC}" # session s, window 0, panes 1 to N - tmux send-keys -t ${S}:${W}.${i} "LLVL=${L} LOGF=./${W}${i}.log chaincli --config /tmp/${W}${i} start --listen tcp://127.0.0.1:${p} --noTLS --proxyaddr 127.0.0.1:${proxy}" C-m + tmux send-keys -t ${S}:${W}.${i} "LLVL=${L} LOGF=./${W}${i}.log chaincli --config /tmp/${W}${i} \ + start --listen tcp://127.0.0.1:${p} --proxyaddr localhost:${proxy} --public grpc://localhost:${p} \ + --routing tree --noTLS" C-m sleep 1 i=$((i + 1)); done @@ -71,48 +73,46 @@ echo -e "${GREEN}[CONNECT]${NC} ${N} nodes and exchange certificates" i=2; p=$((P + 1)) sleep 1 -chaincli --config /tmp/${W}1 minogrpc token -TOKEN=$(chaincli --config /tmp/${W}1 minogrpc token) -echo -e "${GREEN}token: ${TOKEN}${NC}" while [ ${i} -le ${N} ] do echo -e "joining node ${i} on master pane ${MASTERPANE}" - tmux send-keys -t "${MASTERPANE}" "chaincli --config /tmp/${W}${i} minogrpc join --address //127.0.0.1:${p} ${TOKEN}" C-m + tmux send-keys -t "${MASTERPANE}" "chaincli --config /tmp/${W}${i} minogrpc join \ + --address grpc://127.0.0.1:${p} $(chaincli --config /tmp/${W}1 minogrpc token)" C-m sleep 1 i=$((i + 1)); done -#echo -e "${GREEN}[CHAIN]${NC} ${N} nodes" -#i=1; -#m="" -#while [ ${i} -le ${N} ] -#do -# m="${m} --member \$(chaincli --config /tmp/${W}${i} ordering export)" -# i=$((i + 1)); -#done -#tmux send-keys -t "${MASTERPANE}" "chaincli --config /tmp/${W}1 ordering setup ${m}" C-m -# -# -#echo -e "${GREEN}[ACCESS]${NC} setup access rights on each node" -#i=1; -#while [ ${i} -le ${N} ] -#do -# tmux send-keys -t "${MASTERPANE}" "chaincli --config /tmp/${W}${i} access add \ -# --identity $(crypto bls signer read --path ${KEYFILE} --format BASE64_PUBKEY)" C-m -# i=$((i + 1)); -#done -# -# -#echo -e "${GREEN}[GRANT]${NC} grant access for node 1 on the chain" -## sent to master pane -#tmux send-keys -t "${MASTERPANE}" "chaincli --config /tmp/${W}1 pool add \ -# --key ${KEYFILE} \ -# --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access \ -# --args access:grant_id --args 0200000000000000000000000000000000000000000000000000000000000000 \ -# --args access:grant_contract --args go.dedis.ch/dela.Value \ -# --args access:grant_command --args all \ -# --args access:identity --args $(crypto bls signer read --path ${KEYFILE} --format BASE64_PUBKEY) \ -# --args access:command --args GRANT" C-m +echo -e "${GREEN}[CHAIN]${NC} ${N} nodes" +i=1; +m="" +while [ ${i} -le ${N} ] +do + m="${m} --member \$(chaincli --config /tmp/${W}${i} ordering export)" + i=$((i + 1)); +done +tmux send-keys -t "${MASTERPANE}" "chaincli --config /tmp/${W}1 ordering setup ${m}" C-m + + +echo -e "${GREEN}[ACCESS]${NC} setup access rights on each node" +i=1; +while [ ${i} -le ${N} ] +do + tmux send-keys -t "${MASTERPANE}" "chaincli --config /tmp/${W}${i} access add \ + --identity $(crypto bls signer read --path ${KEYFILE} --format BASE64_PUBKEY)" C-m + i=$((i + 1)); +done + + +echo -e "${GREEN}[GRANT]${NC} grant access for node 1 on the chain" +# sent to master pane +tmux send-keys -t "${MASTERPANE}" "chaincli --config /tmp/${W}1 pool add \ + --key ${KEYFILE} \ + --args go.dedis.ch/dela.ContractArg --args go.dedis.ch/dela.Access \ + --args access:grant_id --args 0200000000000000000000000000000000000000000000000000000000000000 \ + --args access:grant_contract --args go.dedis.ch/dela.Value \ + --args access:grant_command --args all \ + --args access:identity --args $(crypto bls signer read --path ${KEYFILE} --format BASE64_PUBKEY) \ + --args access:command --args GRANT" C-m tmux select-pane -t "${MASTERPANE}" diff --git a/server/scripts/teardown.sh b/server/scripts/teardown.sh index c143c3fa..7c3fce37 100755 --- a/server/scripts/teardown.sh +++ b/server/scripts/teardown.sh @@ -13,7 +13,7 @@ S=hbt # session name echo -e "${GREEN}[TMUX tear down]${NC}" #./stop_registry.sh -./stop_smc.sh +#./stop_smc.sh ./stop_chain.sh tmux kill-session -t ${S}