Difference between revisions of "IT-SDK-Hyperledger-Sawtooth"

From wiki.samerhijazi.net
Jump to navigation Jump to search
(Source)
m (Samerhijazi moved page IT-SDK-HyperledgerSawtooth to IT-SDK-Hyperledger-Sawtooth without leaving a redirect)
 
(18 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
* https://www.blockchain-council.org/hyperledger/architecture-of-hyperledger-sawtooth-a-comprehensive-overview/
 
* https://www.blockchain-council.org/hyperledger/architecture-of-hyperledger-sawtooth-a-comprehensive-overview/
  
=Key-Words=
+
=Architektur=
* Commands: sawtooth keygen, sawset
+
* Source: https://github.com/samerhijazi/studying/blob/main/sawtooth/sawtooth-start.yml
* Genesis Block, Genesis Batch, Validators Genesis Block
+
==Key-Words==
* Keys: Public-Key, Private-Key, Validator-Key, Transactor-Key
+
* Validator: checks and ensures that a transaction has a valid signature and directs it to the appropriate transaction processor
* Validator, Transactor, Validator network, ​Validator key generation, User key generation
+
* REST-API:
* Sawtooth Validator, Sawtooth IntegerKey, Sawtooth PoET, Sawtooth XO,
+
* CLI: Command-Line-Interface
 +
* TransactionProcessors: Applications that initiates smart contracts.
 +
* Consensus: Shared agreement. Each network participant waits a randomly-assigned amount of time. The first one to finish waiting becomes the producer of the next block.
  
=Explory=
+
==Components==
Contrary to how we start other blockchains, we do not start bootstrapping Hyperledger Sawtooth with the genesis block creation. We must begin by generating public and private keys for both our user and validator.
+
* Validator: @validator
 +
* REST-API: @rest-api
 +
* CLI: @cli
 +
* TransactionProcessors: @settingTP, @intkeyTP
 +
* Consensus: @devEngine (Devmode consensus engine); @engineA (PoET: Proof-of-Elapsed-Time)
 +
 
 +
=Lify-Cycle=
 +
* Contrary to how we start other blockchains, we do not start bootstrapping Hyperledger Sawtooth with the genesis block creation. We must begin by generating public and private keys for both our user and validator.
 +
<pre class="code">
 +
Configuration: (path.toml, cli.toml, validator.toml)  >>> @validator
 +
Configuration: (rest-api.toml)                        >>> @rest-api
 +
---
 +
Generating: Validator Keys (sawadm keygen)            >>> @validator
 +
Generating: Transactor Keys (sawtooth keygen)          >>> @cli
 +
Generating: Genesis-Batch (sawset genesis)            >>> @validator
 +
Generating: Genesis-Block (sawadm genesis)            >>> @validator
 +
---
 +
Starting: Validator (sawtooth-validator)              >>> @validator
 +
Starting: rest-api (sawtooth-rest-api)                >>> @rest-api
 +
Starting: settingsTP (settings-tp)                    >>> @settingsTP
 +
Starting: intkeyTP (intkey-tp-python)                  >>> @intkeyTP
 +
Starting: devEngine (devmode-engine-rust)              >>> @devEngine
 +
</pre>
 +
 
 +
=Docker-Setting=
 +
* SAWTOOTH_START=https://github.com/samerhijazi/studying/blob/main/sawtooth/sawtooth-start.yml
 +
==Docker-Compose==
 +
<pre class="code">
 +
docker-compose -f $SAWTOOTH_START up -d validator
 +
docker-compose -f $SAWTOOTH_START up -d rest-api
 +
docker-compose -f $SAWTOOTH_START up -d cli
 +
docker-compose -f $SAWTOOTH_START up -d settingsTP
 +
docker-compose -f $SAWTOOTH_START up -d intkeyTP
 +
docker-compose -f $SAWTOOTH_START up -d devEngine
 +
</pre>
 +
==Docker-exec==
 +
<pre class="code">
 +
docker exec -it validator bash
 +
docker exec -it rest-api bash
 +
docker exec -it cli bash
 +
docker exec -it settingsTP bash
 +
docker exec -it intkeyTP bash
 +
docker exec -it devEngine bash
 +
</pre>
  
 
=Commands=
 
=Commands=
 +
* Generating Keys
 +
<pre class="code">
 +
(@validator) sawadm keygen        # /etc/sawtooth/keys/
 +
(@cli) sawtooth keygen student    # ~/.sawtooth/keys/
 +
</pre>
 +
* Generating Genesis
 +
<pre class="code">
 +
(@validator) sawset genesis -k $key_dir/validator.priv -A $key_dir/validator.pub -o /var/lib/sawtooth/sawtooth-settings-genesis.batch
 +
(@validator) sawadm genesis /var/lib/sawtooth/sawtooth-settings-genesis.batch
 +
</pre>
 +
* Starting Components
 +
<pre class="code">
 +
(@validator) sawtooth-validator -vv --​bind "component​:tcp://eth0:8000" --​bind "network​:tcp://eth0:8080" --​bind "consensus​:tcp://eth0:7070" --endpoint "tcp://validatorOne:8080"
 +
(@rest-api)  sawtooth-rest-api -vv -C tcp://validatorOne:8000 --bind rest-api:3000
 +
(@settingTP) settings-tp -vv -C tcp://validatorOne:8000
 +
(@intkeyTP)  intkey-tp-python -vv -C tcp://validatorOne:8000
 +
(@devEngine) devmode-engine-rust -vv --connect tcp://validatorOne:7070
 +
---
 +
(@engineA) poet registration create -o /etc/sawtooth/settings/poet.batch -k /etc/sawtooth/validator.priv
 +
(@engineA) poet enclave measurement > /etc/sawtooth/settings/measurement.txt
 +
(@engineA) poet enclave basename >  /etc/sawtooth/settings/basename.txt
 +
</pre>
 +
 +
=Configuration=
 +
<pre class="code">
 +
(@validator) >>> conf_dir
 +
If SAWTOOTH_HOME is set, conf_dir = SAWTOOTH_HOME/etc/
 +
If SAWTOOTH_HOME is not set, conf_dir = /etc/sawtooth
 +
</pre>
 +
<pre class="code">
 +
(@validator) >>> /etc/sawtooth/path.toml
 +
log_dir = "/var/log/sawtooth"
 +
data_dir = "/var/lib/sawtooth"
 +
key_dir = "/etc/sawtooth/keys"
 +
policy_dir = "/etc/sawtooth/policy"
 +
</pre>
 +
<pre class="code">
 +
(@validator) >>> /etc/sawtooth/cli.toml
 +
url = "http://rest-api:3000"
 +
</pre>
 +
<pre class="code">
 +
(@validator) >>> /etc/sawtooth/validator.toml
 +
bind = [
 +
"component:tcp://validatorOne:8000",
 +
"network:tcp://validatorOne:8080",
 +
"consensus:tcp://validatorOne:7070"
 +
]
 +
endpoint = "tcp://validatorOne:8080"
 +
</pre>
 +
<pre class="code">
 +
(@rest-api) >>> /etc/sawtooth/rest-api.toml
 +
bind = ["rest-api:3000"]
 +
connect = "tcp://validatorOne:8000"
 +
</pre>
 +
 +
=CLI=
 +
<pre class="code">
 +
(@cli) Test the REST API
 +
curl ​ http://​rest-api​:3000/blocks
 +
curl ​ http://rest-api:3000/peers
 +
</pre>
 +
<pre class="code">
 +
sawtooth block list --url http://rest-api​:3000
 +
sawtooth transaction list --url http://rest-api:3000
 +
sawtooth settings list --url http://​rest-api:3000
 +
sawtooth state list --url http://rest-api:3000
 +
sawtooth peer list --url http://​rest-api:3000
 +
</pre>
 +
<pre class="code">
 +
sawset proposal create sawtooth.validator.max_transactions_per_block=1 -k /etc/sawtooth/keys/validator.priv --url http://rest-api:3000
 +
intkey set sample 10 -v --keyfile /root/.sawtooth/keys/student.priv --url http://rest-api:3000
 +
</pre>
 +
 +
=System-Setup=
 
<pre class="code">
 
<pre class="code">
sawtooth-validator -v \
+
sudo apt update
--​bind “component​:tcp://eth0:8000” \
+
sudo apt install curl git apt-transport-https ca-certificates gnupg-agent software-properties-common
--​bind “network​:tcp://eth0:8080” \
+
...
--​bind “consensus​:tcp://eth0:7070”
+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
--endpoint “​tcp://validatorOne:8080”
+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
 +
sudo apt update
 +
sudo apt install docker-ce docker-ce-cli containerd.io
 +
sudo groupadd docker
 +
sudo usermod -aG docker $USER
 
</pre>
 
</pre>

Latest revision as of 18:42, 14 September 2021

Source

Architektur

Key-Words

  • Validator: checks and ensures that a transaction has a valid signature and directs it to the appropriate transaction processor
  • REST-API:
  • CLI: Command-Line-Interface
  • TransactionProcessors: Applications that initiates smart contracts.
  • Consensus: Shared agreement. Each network participant waits a randomly-assigned amount of time. The first one to finish waiting becomes the producer of the next block.

Components

  • Validator: @validator
  • REST-API: @rest-api
  • CLI: @cli
  • TransactionProcessors: @settingTP, @intkeyTP
  • Consensus: @devEngine (Devmode consensus engine); @engineA (PoET: Proof-of-Elapsed-Time)

Lify-Cycle

  • Contrary to how we start other blockchains, we do not start bootstrapping Hyperledger Sawtooth with the genesis block creation. We must begin by generating public and private keys for both our user and validator.
Configuration: (path.toml, cli.toml, validator.toml)   >>> @validator
Configuration: (rest-api.toml)                         >>> @rest-api
---
Generating: Validator Keys (sawadm keygen)             >>> @validator
Generating: Transactor Keys (sawtooth keygen)          >>> @cli
Generating: Genesis-Batch (sawset genesis)             >>> @validator
Generating: Genesis-Block (sawadm genesis)             >>> @validator
---
Starting: Validator (sawtooth-validator)               >>> @validator
Starting: rest-api (sawtooth-rest-api)                 >>> @rest-api
Starting: settingsTP (settings-tp)                     >>> @settingsTP
Starting: intkeyTP (intkey-tp-python)                  >>> @intkeyTP
Starting: devEngine (devmode-engine-rust)              >>> @devEngine

Docker-Setting

Docker-Compose

docker-compose -f $SAWTOOTH_START up -d validator
docker-compose -f $SAWTOOTH_START up -d rest-api
docker-compose -f $SAWTOOTH_START up -d cli
docker-compose -f $SAWTOOTH_START up -d settingsTP
docker-compose -f $SAWTOOTH_START up -d intkeyTP
docker-compose -f $SAWTOOTH_START up -d devEngine

Docker-exec

docker exec -it validator bash
docker exec -it rest-api bash
docker exec -it cli bash
docker exec -it settingsTP bash
docker exec -it intkeyTP bash
docker exec -it devEngine bash

Commands

  • Generating Keys
(@validator) sawadm keygen         # /etc/sawtooth/keys/
(@cli) sawtooth keygen student     # ~/.sawtooth/keys/
  • Generating Genesis
(@validator) sawset genesis -k $key_dir/validator.priv -A $key_dir/validator.pub -o /var/lib/sawtooth/sawtooth-settings-genesis.batch
(@validator) sawadm genesis /var/lib/sawtooth/sawtooth-settings-genesis.batch
  • Starting Components
(@validator) sawtooth-validator -vv --​bind "component​:tcp://eth0:8000" --​bind "network​:tcp://eth0:8080" --​bind "consensus​:tcp://eth0:7070" --endpoint "tcp://validatorOne:8080"
(@rest-api)  sawtooth-rest-api -vv -C tcp://validatorOne:8000 --bind rest-api:3000
(@settingTP) settings-tp -vv -C tcp://validatorOne:8000
(@intkeyTP)  intkey-tp-python -vv -C tcp://validatorOne:8000
(@devEngine) devmode-engine-rust -vv --connect tcp://validatorOne:7070
---
(@engineA) poet registration create -o /etc/sawtooth/settings/poet.batch -k /etc/sawtooth/validator.priv
(@engineA) poet enclave measurement > /etc/sawtooth/settings/measurement.txt
(@engineA) poet enclave basename >  /etc/sawtooth/settings/basename.txt

Configuration

(@validator) >>> conf_dir
If SAWTOOTH_HOME is set, conf_dir = SAWTOOTH_HOME/etc/
If SAWTOOTH_HOME is not set, conf_dir = /etc/sawtooth
(@validator) >>> /etc/sawtooth/path.toml
log_dir = "/var/log/sawtooth"
data_dir = "/var/lib/sawtooth"
key_dir = "/etc/sawtooth/keys"
policy_dir = "/etc/sawtooth/policy"
(@validator) >>> /etc/sawtooth/cli.toml
url = "http://rest-api:3000"
(@validator) >>> /etc/sawtooth/validator.toml
bind = [
"component:tcp://validatorOne:8000",
"network:tcp://validatorOne:8080",
"consensus:tcp://validatorOne:7070"
]
endpoint = "tcp://validatorOne:8080"
(@rest-api) >>> /etc/sawtooth/rest-api.toml
bind = ["rest-api:3000"] 
connect = "tcp://validatorOne:8000"

CLI

(@cli) Test the REST API
curl ​ http://​rest-api​:3000/blocks
curl ​ http://rest-api:3000/peers
sawtooth block list --url http://rest-api​:3000
sawtooth transaction list --url http://rest-api:3000
sawtooth settings list --url http://​rest-api:3000
sawtooth state list --url http://rest-api:3000
sawtooth peer list --url http://​rest-api:3000
sawset proposal create sawtooth.validator.max_transactions_per_block=1 -k /etc/sawtooth/keys/validator.priv --url http://rest-api:3000
intkey set sample 10 -v --keyfile /root/.sawtooth/keys/student.priv --url http://rest-api:3000

System-Setup

sudo apt update
sudo apt install curl git apt-transport-https ca-certificates gnupg-agent software-properties-common
...
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
sudo groupadd docker
sudo usermod -aG docker $USER