Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

feat: support to disable private transaction managers #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions examples/config/qubernetes-no-tm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# see: ./quick-start-gen --help, if you wish to generate this file.
# ./quick-start-gen --chain-id=1000 --tm-name=tessera --num-nodes=4 --consensus=istanbul --quorum-version=21.7.1 --tm-version=21.7.2
# This is the core configuration file, at a minimum include:
# 1. the number of nodes entries
# 2. quorum's consensus (istanbul IBFT, or Raft)
# 3. the version of the quorum container and the transaction manager container.
# Reasonable defaults will be chosen for the rest of the values, ports, associated K8s resources, etc.

k8s:
# persistent storage is handled by Persistent Volume Claims (PVC) https://kubernetes.io/docs/concepts/storage/persistent-volumes/
# test locally and on GCP
# The data dir is persisted here
storage:
# PVC (Persistent_Volume_Claim - tested with GCP).
Type: PVC
## when redeploying cannot be less than previous values
Capacity: 200Mi

# In general, all the nodes should have the same consensus and tm as the genesis and as each other.
genesis:
# supported: (raft | istanbul)
consensus: istanbul
Quorum_Version: 21.7.1
Tm_Version: 21.7.2
Chain_Id: 1000

nodes:

- Node_UserIdent: quorum-node1
Key_Dir: key1
quorum:
quorum:
# supported: (raft | istanbul)
consensus: istanbul
Quorum_Version: 21.7.1

- Node_UserIdent: quorum-node2
Key_Dir: key2
quorum:
quorum:
# supported: (raft | istanbul)
consensus: istanbul
Quorum_Version: 21.7.1


- Node_UserIdent: quorum-node3
Key_Dir: key3
quorum:
quorum:
# supported: (raft | istanbul)
consensus: istanbul
Quorum_Version: 21.7.1


- Node_UserIdent: quorum-node4
Key_Dir: key4
quorum:
quorum:
# supported: (raft | istanbul)
consensus: istanbul
Quorum_Version: 21.7.1

# #add more nodes if you'd like
# - Node_UserIdent: quorum-node5
# Key_Dir: key5
# quorum:
# quorum:
# # supported: (raft | istanbul)
# consensus: istanbul
# Quorum_Version: 21.7.1
# tm:
# # (tessera|constellation)
# Name: tessera
# Tm_Version: 21.7.2
# #add more nodes if you'd like
# - Node_UserIdent: quorum-node6
# Key_Dir: key6
# quorum:
# quorum:
# # supported: (raft | istanbul)
# consensus: istanbul
# Quorum_Version: 21.7.1
# tm:
# # (tessera|constellation)
# Name: tessera
# Tm_Version: 21.7.2
9 changes: 7 additions & 2 deletions qubernetes
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ def set_node_template_vars(values)
@Service_Prefix = (@Node_UserIdent.upcase).gsub("-", "_")
@Node_Key_Dir = values["Key_Dir"]
@Consensus = values["quorum"]["quorum"]["consensus"]
@Tm_Version = values["quorum"]["tm"]["Tm_Version"]
@Tm_Name = values["quorum"]["tm"]["Name"]
if values["quorum"].key?('tm')
@Tm_Version = values["quorum"]["tm"].has_key?('Tm_Version') ? @config["genesis"]["Tm_Version"] : values["quorum"]["tm"]["Tm_Version"]
@Tm_Name = values["quorum"]["tm"].has_key?('Name') ? "none" : values["quorum"]["tm"]["Name"]
else
@Tm_Version = @config["genesis"]["Tm_Version"]
@Tm_Name = "none"
end
@Quorum_Version = values["quorum"]["quorum"]["Quorum_Version"]

@Geth_Verbosity = 9
Expand Down
6 changes: 3 additions & 3 deletions quorum-config
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def set_node_template_vars(values)
@Node_UserIdent = values["Node_UserIdent"]
@Node_Key_Dir = values["Key_Dir"]
@Consensus = values["quorum"]["quorum"]["consensus"]
@Tm_Version = values["quorum"]["tm"]["Tm_Version"]
@Tm_Name = values["quorum"]["tm"]["Name"]
@Tm_Version = values["quorum"]["tm"].has_key('Tm_Version') ? "21.7.2" : values["quorum"]["tm"]["Tm_Version"]
@Tm_Name = values["quorum"]["tm"].has_key('Name') ? "none" : values["quorum"]["tm"]["Name"]
@Quorum_Version = values["quorum"]["quorum"]["Quorum_Version"]

@Geth_Network_Id = @Chain_Id
Expand Down Expand Up @@ -59,7 +59,7 @@ end
@config = YAML.load_file(@config_file)
@nodes = @config["nodes"] #YAML.load_file("nodes.yaml")["nodes"]
@external_nodes = @config["external_nodes"]

@Genesis_Tm_Version = @config["genesis"].has_key?('Tm_Version') ? @config["genesis"]["Tm_Version"] : "0.0.0"
## set defaults for config if not set, else use the values from the config.
@Genesis_Consensus = @config["genesis"]["consensus"]
# used by quorum-shared-config.yaml.erb and quorum-keystore.yaml.erb to load keys.
Expand Down
13 changes: 8 additions & 5 deletions templates/k8s/quorum-deployment.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ spec:
--verbosity=<%= @Geth_Verbosity%> \
--othernodes=https://$QUORUM_NODE1_SERVICE_HOST:<%= @Tm_Port %>/ \";
/usr/local/bin/constellation-node $args 2>&1 | tee -a $QUORUM_HOME/logs/tm.log; "
<%- else -%>
<%- elsif @Tm_Name != "constellation" && @Tm_Name != "none" -%>
- name: tessera
<%- if @TM_Docker_Repo_Full != "" -%>
image: <%= @TM_Docker_Repo_Full %>
Expand Down Expand Up @@ -154,7 +154,6 @@ spec:
java -Xms128M -Xmx128M -jar /tessera/tessera-app.jar -configfile ${DDIR}/tessera-config-with-hosts.json | tee -a ${QHOME}/logs/tessera.log;
<%- end -%>
"
<%- end -%>
ports:
- containerPort: <%= @Tm_Port %>
env:
Expand Down Expand Up @@ -191,6 +190,7 @@ spec:
mountPath: <%= @Node_DataDir %>/tm/tessera-config-9.0.json.tmpl
subPath: tessera-config-9.0.json.tmpl
<%- end -%>
<%- end -%>
- name: quorum
<%- if @Quorum_Docker_Repo_Full != "" -%>
image: <%= @Quorum_Docker_Repo_Full %>
Expand Down Expand Up @@ -221,12 +221,9 @@ spec:
<%- if @Tm_Name == "tessera" -%>
until $(wget --quiet --tries=1 --spider http://127.0.0.1:<%= @Tm_Port %>/upcheck); do echo 'waiting for transaction manager to start...'; sleep 5; done;
echo transaction manager is up;
<%- else -%>
sleep 5;
echo slept for 5 to give TM time to start up;
<%- end -%>


touch $QUORUM_DATA_DIR/password.txt;
NETWORK_ID=<%= @Geth_Network_Id %>
RPC_APIS=admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum
Expand Down Expand Up @@ -279,8 +276,10 @@ spec:
- containerPort: 6060
<% end %>
env:
<%- if @Tm_Name != "none" -%>
- name: PRIVATE_CONFIG
value: <%= @Node_DataDir %>/tm/tm.ipc
<%- end -%>
- name: QUORUM_DATA_DIR
value: <%= @Node_DataDir %>/dd
- name: QUORUM_HOME
Expand Down Expand Up @@ -347,6 +346,7 @@ spec:
items:
- key: genesis-geth.json
path: genesis-geth.json
<%- if @Tm_Name == "tessera" -%>
- name: tessera-config
configMap:
name: tessera-config
Expand All @@ -357,9 +357,11 @@ spec:
path: tessera-config-enhanced.json.tmpl
- key: tessera-config-9.0.json.tmpl
path: tessera-config-9.0.json.tmpl
<%- end -%>
- name: contracts-config
configMap:
name: contracts-config
<%- if @Tm_Name != "none" -%>
- name: keystore-tm
configMap:
name: <%= @Node_UserIdent %>-tm-key-config
Expand All @@ -368,6 +370,7 @@ spec:
path: tm.pub
- key: tm.key
path: tm.key
<%- end -%>
- name: quorum-key-config-persistent-storage
configMap:
name: <%= @Node_UserIdent %>-account-key-config
Expand Down
4 changes: 2 additions & 2 deletions templates/k8s/quorum-keystore.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<%- @nodes.each do |node| -%>
<%= set_node_template_vars(node) -%>

<%- if @Tm_Name != "none" -%>
# quorum transaction manager keys transaction manager key: used for private transactions.
---
apiVersion: v1
Expand All @@ -30,7 +30,7 @@ data:
<%- File.readlines("#{@Key_Dir_Base}/#{@Node_Key_Dir}/tm.pub").each do |line| -%>
<%= line -%>
<% end -%>

<%- end -%>
---
# nodekey private to the node, used to verify identity.
apiVersion: v1
Expand Down
39 changes: 23 additions & 16 deletions templates/k8s/quorum-shared-config.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ metadata:
name: quorum-permissioned-config
data:
permissioned-nodes.json: |

<%- File.readlines(@Permissioned_Nodes_File).each do |line| -%>
<%= line -%>
<% end -%>

<%- end -%>
<%- if @Tm_Name != "none" && @Tm_Name == "tessera" -%>
---
apiVersion: v1
kind: ConfigMap
Expand All @@ -37,7 +36,7 @@ data:
<%- File.readlines(@Tessera_Config_Dir + "/tessera-config-9.0.json").each do |line| -%>
<%= line -%>
<% end -%>

<% end -%>
---
apiVersion: v1
kind: ConfigMap
Expand All @@ -48,20 +47,28 @@ metadata:
app: qubernetes
name: contracts-config
data:
<%- if @Tm_Name != "none" -%>
runscript.sh: |-
<%- File.readlines("contracts/runscript.sh").each do |line| -%>
<%- File.readlines("contracts/runscript.sh").each do |line| -%>
<%= line -%>
<% end -%>
# set the tm.pub for node1 in the privateFor field.
# supports single node deployment.
private_contract.js: |-
<%- tm_key1 = "NOT_SET" -%>
<%- File.readlines("#{@Key_Dir_Base}/key1/tm.pub").each do |line| -%>
<% tm_key1 = line %>
<% end -%>
<%- File.readlines("contracts/private_contract.js").each do |line| -%>
<%- with_valid_key = line.gsub(/"%PRIVATE_FOR_NODE%"/, '"' + tm_key1 + '"') -%>
<%= with_valid_key -%>
<% end -%>
<%- else -%>
runscript.sh: |-
echo ""
<%- end -%>

<%- if @Tm_Name != "none" %>
# set the tm.pub for node1 in the privateFor field.
# supports single node deployment.
private_contract.js: |-
<%- tm_key1 = "NOT_SET" -%>
<%- File.readlines("#{@Key_Dir_Base}/key1/tm.pub").each do |line| -%>
<% tm_key1 = line %>
<% end -%>
<%- File.readlines("contracts/private_contract.js").each do |line| -%>
<%- with_valid_key = line.gsub(/"%PRIVATE_FOR_NODE%"/, '"' + tm_key1 + '"') -%>
<%= with_valid_key -%>
<% end -%>
<% end -%>
public_contract.js: |-
<%- File.readlines("contracts/public_contract.js").each do |line| -%>
Expand Down
6 changes: 4 additions & 2 deletions templates/quorum/gen-keys.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ BASE_DIR=<%= @Key_Dir_Base %>
<%- else %>
BASE_DIR=$(pwd)/<%= @Key_Dir_Base %>
<%- end %>

<%- if @Tm_Name -%>
# try to use openSSL to generate tessera keys, used in docker container.
TESSERA_KEY_GEN_CMD="$(pwd)/templates/quorum/tessera-keygen.sh --keyName tm"
# however, if TESSERA_JAR env var is set, then use tessera to generate the key, e.g. on mac or other local env.
if [[ -n "$TESSERA_JAR" ]]; then
TESSERA_KEY_GEN_CMD="java -jar ${TESSERA_JAR} keygen --keyout tm"
fi

<%- end %>
mkdir -p $BASE_DIR
IFS=', ' read -r -a array <<< "$NODE_DIRS"

Expand All @@ -38,11 +38,13 @@ for node_key_dir in "${array[@]}"; do
shopt -s expand_aliases
mkdir -p $KEY_DIR
cd $KEY_DIR
<%- if @Tm_Name -%>
if [[ -n TESSERA_JAR ]]; then
echo | $TESSERA_KEY_GEN_CMD
else
$TESSERA_KEY_GEN_CMD
fi
<%- end %>
touch password.txt
#geth account new --keystore $KEY_DIR --password password.txt
ethkey generate $KEY_DIR/acctkeyfile.json --passwordfile password.txt
Expand Down
1 change: 0 additions & 1 deletion templates/quorum/genesis.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ if @config["genesis"]["Test_QBFT_Block"]
@Test_QBFT_Block = @config["genesis"]["Test_QBFT_Block"]
end
@Genesis_Quorum_Version = @config["genesis"]["Quorum_Version"]
@Genesis_Tm_Version = @config["genesis"]["Tm_Version"]

@Account_Allocs = ""
@Node_Index = 0
Expand Down