diff --git a/examples/cactus-example-electricity-trade/README.md b/examples/cactus-example-electricity-trade/README.md index 3b1c8ce174d..09b6e13467e 100644 --- a/examples/cactus-example-electricity-trade/README.md +++ b/examples/cactus-example-electricity-trade/README.md @@ -39,13 +39,7 @@ In this example, we use the Sawtooth intkey transaction processor as an applicat - This script will start all ledger docker containers, networks, and will setup configuration needed to operate the sample app. - (NOTICE: Before executing the above, your account needs to be added to the docker group (`usermod -a -G docker YourAccount` from root user)) - On success, this should start the following containers: - - `sawtooth-shell-default` - - `sawtooth-settings-tp-default` - - `sawtooth-intkey-tp-python-default` - - `sawtooth-xo-tp-python-default` - - `sawtooth-rest-api-default` - - `sawtooth-devmode-engine-rust-default` - - `sawtooth-validator-default` + - `sawtooth_all_in_one_ledger_1x` - `geth1` 1. Launch electricity-trade and validators from local `docker-compose.yml` (use separate console for that, docker-compose will block your prompt): @@ -131,10 +125,13 @@ In this example, we use the Sawtooth intkey transaction processor as an applicat ``` # Create intkey batch representing electricity usage - Writing to batches.intkey... - - # Sumbit electricity usage - batches: 2, batch/sec: 159.92313264955962 + { + "link": "http://rest-api:8008/batch_statuses?id=4e85337e170917c138e4f7de44c85c9dea9c5e17916fded672b90adb85a07ca009002580f8629660e26e1117e9ac15f4c1164d9dc05fc77ac8e212672dc5e97a" + } + # Increase usage + { + "link": "http://rest-api:8008/batch_statuses?id=88b4dfa2128c7ad4b646b4fe6be878948f7c17651baf9c6384080a9eaae5036e219c432b46f74331a2d56b80bf2dcc94496ff261d1a941f23210d637badacf14" + } ``` 1. (Optional) Check the balance on Ethereum accounts using the following script diff --git a/examples/cactus-example-electricity-trade/docker-compose.yml b/examples/cactus-example-electricity-trade/docker-compose.yml index b257bfac69e..1cd957dd53f 100644 --- a/examples/cactus-example-electricity-trade/docker-compose.yml +++ b/examples/cactus-example-electricity-trade/docker-compose.yml @@ -27,7 +27,7 @@ services: ports: - "5140:5140" networks: - - sawtooth_net + - sawtooth_aio_testnet_1x - cactus-example-electricity-trade-net volumes: - type: bind @@ -61,7 +61,7 @@ services: target: /etc/cactus networks: - sawtooth_net: + sawtooth_aio_testnet_1x: external: true geth1net: external: true diff --git a/examples/cactus-example-electricity-trade/script-cleanup.sh b/examples/cactus-example-electricity-trade/script-cleanup.sh index 9804add501e..b7c5ee5c1df 100755 --- a/examples/cactus-example-electricity-trade/script-cleanup.sh +++ b/examples/cactus-example-electricity-trade/script-cleanup.sh @@ -6,13 +6,7 @@ echo ">> Remove the config files on your machine" rm -rf ./etc/cactus/ echo ">> Stop and remove the docker containers" -docker rm -f sawtooth-shell-default \ - sawtooth-settings-tp-default \ - sawtooth-intkey-tp-python-default \ - sawtooth-xo-tp-python-default \ - sawtooth-rest-api-default \ - sawtooth-devmode-engine-rust-default \ - sawtooth-validator-default \ +docker rm -f sawtooth_all_in_one_ledger_1x \ geth1 \ cactus-example-electricity-trade-blp \ cactus-example-electricity-trade-ethereum-validator \ @@ -20,9 +14,9 @@ docker rm -f sawtooth-shell-default \ cmd-socketio-base-dummy echo ">> Remove docker networks" -docker network rm sawtooth_net \ - electricity-trade_default \ - electricity-trade_electricity-trade-net \ +docker network rm sawtooth_aio_testnet_1x \ + cactus-example-electricity-trade_default \ + cactus-example-electricity-trade_cactus-example-electricity-trade-net \ geth1net \ geth-testnet_default diff --git a/examples/cactus-example-electricity-trade/script-gen-electricity-usage.sh b/examples/cactus-example-electricity-trade/script-gen-electricity-usage.sh index c57b3bb744d..85f51587e02 100755 --- a/examples/cactus-example-electricity-trade/script-gen-electricity-usage.sh +++ b/examples/cactus-example-electricity-trade/script-gen-electricity-usage.sh @@ -2,8 +2,8 @@ # Copyright 2020-2022 Hyperledger Cactus Contributors # SPDX-License-Identifier: Apache-2.0 -echo "# Create intkey batch representing electricity usage" -docker exec -it sawtooth-shell-default intkey create_batch --key-name MI000001 --value-set 50 --value-inc 24 +echo "# Create intkey representing electricity usage" +docker exec -t sawtooth_all_in_one_ledger_1x shell intkey set MI000001 50 --url http://rest-api:8008 -echo -e "\n# Sumbit electricity usage" -docker exec -it sawtooth-shell-default sawtooth batch submit -f batches.intkey --url http://rest-api:8008 +echo "# Increase usage" +docker exec -t sawtooth_all_in_one_ledger_1x shell intkey inc MI000001 24 --url http://rest-api:8008 diff --git a/examples/cactus-example-electricity-trade/script-get-app.sh b/examples/cactus-example-electricity-trade/script-get-app.sh index 9a3dab536b6..1ac6f59cb25 100755 --- a/examples/cactus-example-electricity-trade/script-get-app.sh +++ b/examples/cactus-example-electricity-trade/script-get-app.sh @@ -9,4 +9,4 @@ echo -e "\n\n# Destination Eth balance:" curl localhost:5034/api/v1/bl/balance/9d624f7995e8bd70251f8265f2f9f2b49f169c55 echo -e "\n\n# Electricity usage" -docker exec -it sawtooth-shell-default intkey list --url http://rest-api:8008 +docker exec -t sawtooth_all_in_one_ledger_1x shell intkey list --url http://rest-api:8008 diff --git a/examples/cactus-example-electricity-trade/script-start-ledgers.sh b/examples/cactus-example-electricity-trade/script-start-ledgers.sh index 01f736adcee..1c9e8647792 100755 --- a/examples/cactus-example-electricity-trade/script-start-ledgers.sh +++ b/examples/cactus-example-electricity-trade/script-start-ledgers.sh @@ -6,6 +6,9 @@ set -e ROOT_DIR="../.." # Path to cactus root dir CONFIG_VOLUME_PATH="./etc/cactus" # Docker volume with shared configuration +WAIT_TIME=10 # How often to check container status + +export CACTUS_SAWTOOTH_LEDGER_CONTAINER_NAME="sawtooth_all_in_one_ledger_1x" # Cert options CERT_CURVE_NAME="prime256v1" @@ -66,12 +69,19 @@ function copy_ethereum_validator_config() { } function start_sawtooth_testnet() { - pushd "${ROOT_DIR}/tools/docker/sawtooth-testnet" + pushd "${ROOT_DIR}/tools/docker/sawtooth-all-in-one" ./script-start-docker.sh popd - # Patch create_batch with our logic (will generate electricity usage) - docker cp ./tools/create_batch/create_batch3.py sawtooth-shell-default:/usr/lib/python3/dist-packages/sawtooth_intkey/client_cli/create_batch.py + # Wait for fabric cotnainer to become healthy + health_status="$(docker inspect -f '{{.State.Health.Status}}' ${CACTUS_SAWTOOTH_LEDGER_CONTAINER_NAME})" + while ! [ "${health_status}" == "healthy" ] + do + echo "Waiting for sawtooth container... current status => ${health_status}" + sleep $WAIT_TIME + health_status="$(docker inspect -f '{{.State.Health.Status}}' ${CACTUS_SAWTOOTH_LEDGER_CONTAINER_NAME})" + done + echo ">> Sawtooth ${CACTUS_FABRIC_ALL_IN_ONE_VERSION} started." } function copy_sawtooth_validator_config() { diff --git a/examples/cactus-example-electricity-trade/tools/create_batch/create_batch3.py b/examples/cactus-example-electricity-trade/tools/create_batch/create_batch3.py deleted file mode 100644 index 55cba28624d..00000000000 --- a/examples/cactus-example-electricity-trade/tools/create_batch/create_batch3.py +++ /dev/null @@ -1,327 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2016 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ------------------------------------------------------------------------------ - -import argparse -import hashlib -import os -import logging -import random -import string -import time -import cbor - -from sawtooth_signing import create_context -from sawtooth_signing import CryptoFactory - -from sawtooth_sdk.protobuf import batch_pb2 -from sawtooth_sdk.protobuf import transaction_pb2 - -from sawtooth_intkey.processor.handler import make_intkey_address - - -LOGGER = logging.getLogger(__name__) - - -class IntKeyPayload: - def __init__(self, verb, name, value): - self._verb = verb - self._name = name - self._value = value - - self._cbor = None - self._sha512 = None - - def to_hash(self): - return { - 'Verb': self._verb, - 'Name': self._name, - 'Value': self._value - } - - def to_cbor(self): - if self._cbor is None: - self._cbor = cbor.dumps(self.to_hash(), sort_keys=True) - return self._cbor - - def sha512(self): - if self._sha512 is None: - self._sha512 = hashlib.sha512(self.to_cbor()).hexdigest() - return self._sha512 - - -def create_intkey_transaction(verb, name, value, deps, signer): - """Creates a signed intkey transaction. - - Args: - verb (str): the action the transaction takes, either 'set', 'inc', - or 'dec' - name (str): the variable name which is altered by verb and value - value (int): the amount to set, increment, or decrement - deps ([str]): a list of transaction header_signatures which are - required dependencies which must be processed prior to - processing this transaction - signer (:obj:`Signer`): the cryptographic signer for signing the - transaction - - Returns: - transaction (transaction_pb2.Transaction): the signed intkey - transaction - """ - payload = IntKeyPayload( - verb=verb, name=name, value=value) - - # The prefix should eventually be looked up from the - # validator's namespace registry. - addr = make_intkey_address(name) - - header = transaction_pb2.TransactionHeader( - signer_public_key=signer.get_public_key().as_hex(), - family_name='intkey', - family_version='1.0', - inputs=[addr], - outputs=[addr], - dependencies=deps, - payload_sha512=payload.sha512(), - batcher_public_key=signer.get_public_key().as_hex(), - nonce=hex(random.randint(0, 2**64))) - - header_bytes = header.SerializeToString() - - signature = signer.sign(header_bytes) - - transaction = transaction_pb2.Transaction( - header=header_bytes, - payload=payload.to_cbor(), - header_signature=signature) - - return transaction - - -def create_batch(transactions, signer): - transaction_signatures = [t.header_signature for t in transactions] - - header = batch_pb2.BatchHeader( - signer_public_key=signer.get_public_key().as_hex(), - transaction_ids=transaction_signatures) - - header_bytes = header.SerializeToString() - - signature = signer.sign(header_bytes) - - batch = batch_pb2.Batch( - header=header_bytes, - transactions=transactions, - header_signature=signature) - - return batch - - -def generate_word(): - return ''.join([random.choice(string.ascii_letters) for _ in range(0, 6)]) - - -def generate_word_list(count): - if os.path.isfile('/usr/share/dict/words'): - with open('/usr/share/dict/words', 'r') as fd: - return {x.strip(): None for x in fd.readlines()[0:count]} - else: - return {generate_word(): None for _ in range(0, count)} - - -def do_populate(batches, keys, value): - context = create_context('secp256k1') - private_key = context.new_random_private_key() - crypto_factory = CryptoFactory(context) - signer = crypto_factory.new_signer(private_key) - - total_txn_count = 0 - txns = [] - for i in range(0, len(keys)): - name = list(keys)[i] - txn = create_intkey_transaction( - verb='set', - name=name, - # value=random.randint(9000, 100000), - value=value, - deps=[], - signer=signer) - total_txn_count += 1 - txns.append(txn) - # Establish the signature of the txn associated with the word - # so we can create good dependencies later - keys[name] = txn.header_signature - - batch = create_batch( - transactions=txns, - signer=signer) - - if value >= 0: - batches.append(batch) - - -def do_generate(args, batches, keys, value, bNeedSetDesp): - context = create_context('secp256k1') - private_key = context.new_random_private_key() - crypto_factory = CryptoFactory(context) - signer = crypto_factory.new_signer(private_key) - - start = time.time() - total_txn_count = 0 - for i in range(1): - txns = [] - for _ in range(1): - name = random.choice(list(keys)) - txn = create_intkey_transaction( - # verb=random.choice(['inc', 'dec']), - verb='inc', - name=name, - # value=random.randint(1, 10), - value=value, - # deps=[keys[name]], - deps= [keys[name]] if bNeedSetDesp else [], - signer=signer) - total_txn_count += 1 - txns.append(txn) - - batch = create_batch( - transactions=txns, - signer=signer) - - batches.append(batch) - - if i % 100 == 0 and i != 0: - stop = time.time() - - txn_count = 0 - for batch in batches[-100:]: - txn_count += len(batch.transactions) - - fmt = 'batches {}, batch/sec: {:.2f}, txns: {}, txns/sec: {:.2f}' - print(fmt.format( - str(i), - 100 / (stop - start), - str(total_txn_count), - txn_count / (stop - start))) - start = stop - - -def write_batch_file(args, batches): - batch_list = batch_pb2.BatchList(batches=batches) - print("Writing to {}...".format(args.output)) - with open(args.output, "wb") as fd: - fd.write(batch_list.SerializeToString()) - - -def do_create_batch(args): - # print("##in do_create_batch") - batches = [] - # print("##args.key_count", args.key_count) - # print("##args.key_name", args.key_name) - # keys = generate_word_list(args.key_count) - keys = {args.key_name: None} - # print("##keys", keys) - # do_populate(batches, keys) - # print("##args.value_set", args.value_set) - do_populate(batches, keys, args.value_set) - # print("##batches", batches) - # do_generate(args, batches, keys) - # print("##args.value_inc", args.value_inc) - # print("##args.value_inc_rand", args.value_inc_rand) - - value_inc = args.value_inc - if args.value_inc_rand >= 1: - value_inc = random.randint(1, args.value_inc_rand) - print("##inc value(random)", value_inc) - - if value_inc >= 0: - # print("##call do_generate()") - do_generate(args, batches, keys, value_inc, args.value_set >= 0) - - # print("##args", args) - write_batch_file(args, batches) - - -def add_create_batch_parser(subparsers, parent_parser): - - epilog = ''' - details: - create sample batch(es) of intkey transactions. - populates state with intkey key/value pairs - then generates batches with inc and dec transactions. - ''' - - parser = subparsers.add_parser( - 'create_batch', - parents=[parent_parser], - formatter_class=argparse.RawDescriptionHelpFormatter, - epilog=epilog) - - parser.add_argument( - '-o', '--output', - type=str, - help='location of output file', - default='batches.intkey', - metavar='') - - parser.add_argument( - '-c', '--count', - type=int, - help='number of batches modifying random keys', - default=1, - metavar='') - - parser.add_argument( - '-B', '--max-batch-size', - type=int, - help='max transactions per batch', - default=10, - metavar='') - - parser.add_argument( - '-K', '--key-count', - type=int, - help='number of keys to set initially', - default=1, - metavar='') - - parser.add_argument( - '-n', '--key-name', - type=str, - help='name of key', - default='key1', - metavar='') - - parser.add_argument( - '-s', '--value-set', - type=int, - help='value of set', - default=-1, - metavar='') - - parser.add_argument( - '-i', '--value-inc', - type=int, - help='value of inc', - default=-1, - metavar='') - - parser.add_argument( - '-r', '--value-inc-rand', - type=int, - help='value of inc(random max)', - default=0, - metavar='') diff --git a/packages/cactus-plugin-ledger-connector-sawtooth-socketio/README.md b/packages/cactus-plugin-ledger-connector-sawtooth-socketio/README.md index 35fce1fceb8..6c0ab2678a7 100644 --- a/packages/cactus-plugin-ledger-connector-sawtooth-socketio/README.md +++ b/packages/cactus-plugin-ledger-connector-sawtooth-socketio/README.md @@ -25,7 +25,7 @@ This plugin provides `Cactus` a way to interact with Hyperledger Sawtooth networ - node.js v12 (recommend: v12.20.2 or greater) ### Prerequisites -- Please ensure that the destination ledger (default: [sawtooth-testnet](../../tools/docker/sawtooth-testnet)) is already launched. +- Please ensure that the destination ledger (default: [sawtooth-all-in-one](../../tools/docker/sawtooth-all-in-one)) is already launched. ## Boot methods diff --git a/packages/cactus-plugin-ledger-connector-sawtooth-socketio/sample-config/default.yaml b/packages/cactus-plugin-ledger-connector-sawtooth-socketio/sample-config/default.yaml index abed1e1a6a8..07b508c4967 100644 --- a/packages/cactus-plugin-ledger-connector-sawtooth-socketio/sample-config/default.yaml +++ b/packages/cactus-plugin-ledger-connector-sawtooth-socketio/sample-config/default.yaml @@ -5,7 +5,7 @@ sslParam: blockMonitor: request: method: "GET" - host: "http://rest-api:8008/" + host: "http://sawtooth_all_in_one_ledger_1x:8008/" getLatestBlockNumberCommand: "blocks?limit=1" periodicMonitoringCommand1: "blocks?start=" periodicMonitoringCommand2: "&reverse" diff --git a/packages/cactus-test-tooling/src/main/typescript/public-api.ts b/packages/cactus-test-tooling/src/main/typescript/public-api.ts index 055b3597b29..7d9a41a67b0 100755 --- a/packages/cactus-test-tooling/src/main/typescript/public-api.ts +++ b/packages/cactus-test-tooling/src/main/typescript/public-api.ts @@ -154,6 +154,12 @@ export { RustcContainer, } from "./rustc-container/rustc-container"; +export { + ISawtoothTestLedgerOptions, + SAWTOOTH_LEDGER_DEFAULT_OPTIONS, + SawtoothTestLedger, +} from "./sawtooth/sawtooth-test-ledger"; + export { ISubstrateTestLedgerOptions, SubstrateTestLedger, diff --git a/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-mp-test-ledger.ts b/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-mp-test-ledger.ts index 62c53cc4aad..6571ebb5dcd 100644 --- a/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-mp-test-ledger.ts +++ b/packages/cactus-test-tooling/src/main/typescript/quorum/quorum-mp-test-ledger.ts @@ -32,7 +32,6 @@ export class QuorumMultiPartyTestLedger implements ITestLedger { public containerId: string | undefined; constructor(public readonly options: IQuorumMultiPartyTestLedgerOptions) { - // @todo Replace with hyperledger ghcr link when available this.containerImageName = options?.containerImageName || "ghcr.io/hyperledger/cactus-quorum-multi-party-all-in-one"; diff --git a/packages/cactus-test-tooling/src/main/typescript/sawtooth/sawtooth-test-ledger.ts b/packages/cactus-test-tooling/src/main/typescript/sawtooth/sawtooth-test-ledger.ts new file mode 100644 index 00000000000..c68311bf391 --- /dev/null +++ b/packages/cactus-test-tooling/src/main/typescript/sawtooth/sawtooth-test-ledger.ts @@ -0,0 +1,337 @@ +/** + * Helper utils for setting up and starting Sawtooth ledger for testing. + */ + +import { EventEmitter } from "events"; +import Docker, { Container, ContainerCreateOptions } from "dockerode"; +import { + Bools, + Logger, + LoggerProvider, + LogLevelDesc, +} from "@hyperledger/cactus-common"; +import { ITestLedger } from "../i-test-ledger"; +import { Containers } from "../common/containers"; +import { v4 as internalIpV4 } from "internal-ip"; + +/** + * Type of input parameters to `SawtoothTestLedger` constructor. + */ +export interface ISawtoothTestLedgerOptions { + readonly containerImageName?: string; + readonly containerImageVersion?: string; + readonly ledgerApiPort?: number; + readonly logLevel?: LogLevelDesc; + readonly emitContainerLogs?: boolean; + readonly envVars?: string[]; + // For test development, attach to ledger that is already running, don't spin up new one + readonly useRunningLedger?: boolean; +} + +/** + * Default options for Sawtooth test ledger. + */ +const DEFAULTS = Object.freeze({ + // @todo Replace with hyperledger ghcr link when available + containerImageName: "ghcr.io/hyperledger/cactus-sawtooth-all-in-one", + containerImageVersion: "2022-07-20-bb7a75cb", + ledgerApiPort: 8008, + logLevel: "info" as LogLevelDesc, + emitContainerLogs: false, + envVars: [], + useRunningLedger: false, +}); +export const SAWTOOTH_LEDGER_DEFAULT_OPTIONS = DEFAULTS; + +/** + * Class for running a test sawtooth ledger in a container. + */ +export class SawtoothTestLedger implements ITestLedger { + public readonly containerImageName: string; + public readonly containerImageVersion: string; + private readonly ledgerApiPort: number; + private readonly logLevel: LogLevelDesc; + private readonly emitContainerLogs: boolean; + private readonly useRunningLedger: boolean; + private readonly envVars: string[]; + + private readonly log: Logger; + public container: Container | undefined; + public containerId: string | undefined; + + constructor(public readonly options: ISawtoothTestLedgerOptions) { + this.containerImageName = + options?.containerImageName || DEFAULTS.containerImageName; + + this.containerImageVersion = + options?.containerImageVersion || DEFAULTS.containerImageVersion; + + this.ledgerApiPort = options?.ledgerApiPort || DEFAULTS.ledgerApiPort; + + this.logLevel = options?.logLevel || DEFAULTS.logLevel; + + this.emitContainerLogs = Bools.isBooleanStrict(options.emitContainerLogs) + ? (options.emitContainerLogs as boolean) + : DEFAULTS.emitContainerLogs; + + this.useRunningLedger = Bools.isBooleanStrict(options.useRunningLedger) + ? (options.useRunningLedger as boolean) + : DEFAULTS.useRunningLedger; + + this.envVars = options?.envVars || DEFAULTS.envVars; + + this.log = LoggerProvider.getOrCreate({ + level: this.logLevel, + label: "sawtooth-test-ledger", + }); + } + + /** + * Sawtooth ledger image name and tag + */ + public get fullContainerImageName(): string { + return [this.containerImageName, this.containerImageVersion].join(":"); + } + + /** + * Start a test sawtooth ledger. + * + * @param omitPull Don't pull docker image from upstream if true. + * @returns Promise + */ + public async start(omitPull = false): Promise { + if (this.useRunningLedger) { + this.log.info( + "Search for already running Sawtooth Test Ledger because 'useRunningLedger' flag is enabled.", + ); + this.log.info( + "Search criteria - image name: ", + this.fullContainerImageName, + ", state: running", + ); + const containerInfo = await Containers.getByPredicate( + (ci) => + ci.Image === this.fullContainerImageName && ci.State === "running", + ); + const docker = new Docker(); + this.containerId = containerInfo.Id; + this.container = docker.getContainer(this.containerId); + return this.container; + } + + if (this.container) { + await this.container.stop(); + await this.container.remove(); + this.container = undefined; + this.containerId = undefined; + } + + if (!omitPull) { + await Containers.pullImage( + this.fullContainerImageName, + {}, + this.logLevel, + ); + } + + const createOptions: ContainerCreateOptions = { + ExposedPorts: { + "8008/tcp": {}, // Rest API + }, + Env: this.envVars, + HostConfig: { + PublishAllPorts: true, + Privileged: true, + }, + }; + + return new Promise((resolve, reject) => { + const docker = new Docker(); + const eventEmitter: EventEmitter = docker.run( + this.fullContainerImageName, + [], + [], + createOptions, + {}, + (err: unknown) => { + if (err) { + reject(err); + } + }, + ); + + eventEmitter.once("start", async (container: Container) => { + this.container = container; + this.containerId = container.id; + + if (this.emitContainerLogs) { + const fnTag = `[${this.fullContainerImageName}]`; + await Containers.streamLogs({ + container: this.container, + tag: fnTag, + log: this.log, + }); + } + + try { + await Containers.waitForHealthCheck(this.containerId); + resolve(container); + } catch (ex) { + this.log.error(ex); + reject(ex); + } + }); + }); + } + + /** + * Stop a test sawtooth ledger. + * + * @returns Stop operation results. + */ + public stop(): Promise { + if (this.useRunningLedger) { + this.log.info("Ignore stop request because useRunningLedger is enabled."); + return Promise.resolve(); + } else if (this.container) { + return Containers.stop(this.container); + } else { + return Promise.reject( + new Error( + `SawtoothTestLedger#destroy() Container was never created, nothing to stop.`, + ), + ); + } + } + + /** + * Destroy a test sawtooth ledger. + * + * @returns Destroy operation results. + */ + public destroy(): Promise { + if (this.useRunningLedger) { + this.log.info( + "Ignore destroy request because useRunningLedger is enabled.", + ); + return Promise.resolve(); + } else if (this.container) { + return this.container.remove(); + } else { + return Promise.reject( + new Error( + `SawtoothTestLedger#destroy() Container was never created, nothing to destroy.`, + ), + ); + } + } + + /** + * Get localhost port that can be used to access ledger rest API in the container. + * + * @returns port + */ + private async getRestApiPort() { + if (this.containerId) { + const cInfo = await Containers.getById(this.containerId); + return Containers.getPublicPort(this.ledgerApiPort, cInfo); + } else { + throw new Error( + "getRestApiPort(): Container ID not set. Did you call start()?", + ); + } + } + + /** + * Get localhost URL that can be used to access ledger rest API in the container. + * + * @returns Sawtooth Rest API URL. + */ + public async getRestApiHost(): Promise { + const port = await this.getRestApiPort(); + const lanAddress = (await internalIpV4()) ?? "127.0.0.1"; + return `http://${lanAddress}:${port}`; + } + + /** + * Execute Sawtooth shell command on the ledger. + * + * @param cmd Tokenized command to be executed. + * @param timeout Docker exec timeout (default: 1 minute) + * @param workdir Where to execute the command from (default: undefined) + * + * @returns Command response. + */ + public async runSawtoothShell( + cmd: string[], + timeout = 60 * 1000, + workdir?: string, + ): Promise { + if (this.container) { + // Pass the command to shell helper script in the container + cmd.unshift("shell"); + + if (!cmd.includes("--url")) { + this.log.debug("Append URL argument to the shell command"); + cmd.push("--url", "http://rest-api:8008"); + } + + this.log.debug("Run Sawtooth shell command:", cmd); + + return Containers.exec( + this.container, + cmd, + timeout, + this.logLevel, + workdir, + ); + } else { + throw new Error( + "runSawtoothShell(): Container not set. Did you call start()?", + ); + } + } + + /** + * Check transaction status when supplied with sawtooth status check URL. + * Will execute curl on the URL and block until status is other then PENDING. + * + * @param url Sawtooth batch statuses URL for given transaction (like http://rest-api:8008/batch_statuses?id=) + * @param timeout How many seconds to wait for transaction commit. + * + * @returns Transaction status. + */ + public async waitOnTransaction(url: string, timeout = 30): Promise { + this.log.debug("Wait on transaction with URL", url); + + const checkStatus = async () => { + // Fetch status + const curlResponse = await this.runSawtoothShell(["curl", url]); + this.log.debug("CURL response:", curlResponse); + // Clear response (it's a string with request status appended at the end) + const responseObject = curlResponse.match(/{[\s\S]*}/g) as any; + const parsedResponse = JSON.parse(responseObject); + this.log.debug("Parsed response:", parsedResponse); + return parsedResponse.data[0].status; + }; + + const currentCount = 0; + let status = await checkStatus(); + this.log.debug("Init status:", status); + while (status === "PENDING") { + if (currentCount >= timeout) { + throw new Error(`waitOnTransaction(): timeout for URL '${url}'`); + } + + // Sleep 1 second + await new Promise((resolve) => setTimeout(resolve, 1000)); + + status = await checkStatus(); + this.log.debug("New status:", status); + timeout++; + } + + this.log.info("TX finished. Status:", status); + return status; + } +} diff --git a/tools/docker/sawtooth-all-in-one/Dockerfile b/tools/docker/sawtooth-all-in-one/Dockerfile new file mode 100644 index 00000000000..1feec739f85 --- /dev/null +++ b/tools/docker/sawtooth-all-in-one/Dockerfile @@ -0,0 +1,37 @@ +FROM docker:20.10.17-dind + +# Install docker-compose and it's dependencies +RUN apk update \ + && apk add --no-cache \ + py-pip \ + python3-dev \ + libffi-dev \ + openssl-dev \ + gcc \ + libc-dev \ + rust \ + cargo \ + make \ + supervisor \ + && pip install wheel \ + && pip install docker-compose + +# Copy sawtooth docker-compose +COPY ./sawtooth-default.yaml /app/docker-compose.yaml + +# Copy sawtooth shell helper +COPY ./shell.sh /bin/shell +RUN chmod +x /bin/shell + +# Setup healtcheck +COPY ./healthcheck.sh /bin/healthcheck +RUN chmod +x /bin/healthcheck +HEALTHCHECK --interval=5s --timeout=5s --start-period=30s --retries=60 CMD /bin/healthcheck + +# Expose ledger ports +EXPOSE 8008 + +# Setup supervisor entrypoint +COPY supervisord.conf /etc/supervisord.conf +ENTRYPOINT ["/usr/bin/supervisord"] +CMD ["--configuration", "/etc/supervisord.conf", "--nodaemon"] diff --git a/tools/docker/sawtooth-all-in-one/README.md b/tools/docker/sawtooth-all-in-one/README.md new file mode 100644 index 00000000000..aebffd78a36 --- /dev/null +++ b/tools/docker/sawtooth-all-in-one/README.md @@ -0,0 +1,46 @@ +# sawtooth-all-in-one + +An all in one sawtooth docker image as described in [Sawtooth Documentation](https://sawtooth.hyperledger.org/docs/1.2/app_developers_guide/creating_sawtooth_network.html). +- This docker image is for `testing` and `development` only. +- **Do NOT use in production!** + +## Usage + +### Docker Compose +``` bash +./script-start-docker.sh +``` + +or manually: + +``` bash +docker-compose build && docker-compose up -d +``` + +### Docker +> Excute from `tools/docker/sawtooth-all-in-one` or adjust the paths accordingly. + +``` bash +# Build +DOCKER_BUILDKIT=1 docker build . -t cactus-sawtooth-all-in-one + +# Run +docker run --name sawtooth_all_in_one_ledger_1x --detach --privileged -p 8008:8008 cactus-sawtooth-all-in-one +``` + +## Shell +Image contains a tool that simplifies executing sawtooth commands on the test ledger. + +### Example - set and list intkeys + +``` bash +# Set new key +docker exec -t sawtooth_all_in_one_ledger_1x shell intkey set MI000001 50 --url http://rest-api:8008 + +# List all keys +docker exec -t sawtooth_all_in_one_ledger_1x shell intkey list --url http://rest-api:8008 +``` + +## Test Setup +- There is a helper class that can be used to setup this sawtooth ledger container from JS/TS test - [sawtooth-test-ledger.ts](../../../packages/cactus-test-tooling/src/main/typescript/sawtooth/sawtooth-test-ledger.ts) +- For use examples see sawtooth connector tests. diff --git a/tools/docker/sawtooth-all-in-one/docker-compose.yml b/tools/docker/sawtooth-all-in-one/docker-compose.yml new file mode 100644 index 00000000000..d5ca5e38fb8 --- /dev/null +++ b/tools/docker/sawtooth-all-in-one/docker-compose.yml @@ -0,0 +1,19 @@ +version: "3.5" + +services: + sawtooth-all-in-one-ledger-1x: + container_name: ${CACTUS_SAWTOOTH_LEDGER_CONTAINER_NAME:-sawtooth_all_in_one_ledger_1x} + image: ${CACTUS_SAWTOOTH_LEDGER_IMAGE_NAME:-sawtooth_aio_1x:1.0.0} + privileged: true + build: + context: ./ + dockerfile: Dockerfile + ports: + - "8008:8008" # Rest API + networks: + - sawtooth-network + +networks: + sawtooth-network: + name: sawtooth_aio_testnet_1x + driver: bridge diff --git a/tools/docker/sawtooth-all-in-one/healthcheck.sh b/tools/docker/sawtooth-all-in-one/healthcheck.sh new file mode 100755 index 00000000000..95a93425efd --- /dev/null +++ b/tools/docker/sawtooth-all-in-one/healthcheck.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +# Fail on first wrong command +set -e + +# Get blocks +wget -O- http://localhost:8008/blocks diff --git a/tools/docker/sawtooth-testnet/sawtooth-default.yaml b/tools/docker/sawtooth-all-in-one/sawtooth-default.yaml similarity index 90% rename from tools/docker/sawtooth-testnet/sawtooth-default.yaml rename to tools/docker/sawtooth-all-in-one/sawtooth-default.yaml index 96cf56ada0f..84fcfedf50b 100644 --- a/tools/docker/sawtooth-testnet/sawtooth-default.yaml +++ b/tools/docker/sawtooth-all-in-one/sawtooth-default.yaml @@ -13,6 +13,8 @@ # limitations under the License. # ------------------------------------------------------------------------------ +# Upstream source: https://github.com/hyperledger/sawtooth-core/blob/1-2/docker/compose/sawtooth-default.yaml + version: "2.1" services: @@ -23,8 +25,6 @@ services: depends_on: - validator entrypoint: settings-tp -vv -C tcp://validator:4004 - networks: - - sawtooth_net intkey-tp-python: image: hyperledger/sawtooth-intkey-tp-python:1.2.3 @@ -32,8 +32,6 @@ services: depends_on: - validator entrypoint: intkey-tp-python -vv -C tcp://validator:4004 - networks: - - sawtooth_net xo-tp-python: image: hyperledger/sawtooth-xo-tp-python:1.2.3 @@ -41,8 +39,6 @@ services: depends_on: - validator entrypoint: xo-tp-python -vv -C tcp://validator:4004 - networks: - - sawtooth_net validator: image: hyperledger/sawtooth-validator:1.2.6 @@ -68,8 +64,6 @@ services: --bind network:tcp://eth0:8800 \ --bind consensus:tcp://eth0:5050 \ \"" - networks: - - sawtooth_net devmode-engine: image: hyperledger/sawtooth-devmode-engine-rust:1.2.3 @@ -77,8 +71,6 @@ services: depends_on: - validator entrypoint: devmode-engine-rust -C tcp://validator:5050 - networks: - - sawtooth_net rest-api: image: hyperledger/sawtooth-rest-api:1.2.6 @@ -88,8 +80,6 @@ services: depends_on: - validator entrypoint: sawtooth-rest-api -C tcp://validator:4004 --bind rest-api:8008 - networks: - - sawtooth_net shell: image: hyperledger/sawtooth-shell:1.2.6 @@ -100,9 +90,3 @@ services: sawtooth keygen && \ tail -f /dev/null \ \"" - networks: - - sawtooth_net - -networks: - sawtooth_net: - external: true \ No newline at end of file diff --git a/tools/docker/sawtooth-all-in-one/script-start-docker.sh b/tools/docker/sawtooth-all-in-one/script-start-docker.sh new file mode 100755 index 00000000000..654f4da29bd --- /dev/null +++ b/tools/docker/sawtooth-all-in-one/script-start-docker.sh @@ -0,0 +1,2 @@ +echo "[process] start docker environment for Sawtooth testnet" +docker-compose build && docker-compose up -d diff --git a/tools/docker/sawtooth-all-in-one/shell.sh b/tools/docker/sawtooth-all-in-one/shell.sh new file mode 100755 index 00000000000..914f3b4e514 --- /dev/null +++ b/tools/docker/sawtooth-all-in-one/shell.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +# Simple helper that will proxy sawtooth commands into shell container. + +docker exec -it sawtooth-shell-default "$@" diff --git a/tools/docker/sawtooth-all-in-one/supervisord.conf b/tools/docker/sawtooth-all-in-one/supervisord.conf new file mode 100644 index 00000000000..7a8e1d77618 --- /dev/null +++ b/tools/docker/sawtooth-all-in-one/supervisord.conf @@ -0,0 +1,23 @@ +[supervisord] +logfile = /var/log/supervisord.log +logfile_maxbytes = 50MB +logfile_backups=10 +loglevel = info + +[program:dockerd] +command=dockerd-entrypoint.sh +autostart=true +autorestart=true +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 + +[program:sawtooth-test-ledger] +command=docker-compose -f /app/docker-compose.yaml up +autostart=true +autorestart=false +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 diff --git a/tools/docker/sawtooth-testnet/README.md b/tools/docker/sawtooth-testnet/README.md deleted file mode 100644 index 4ffd78e9006..00000000000 --- a/tools/docker/sawtooth-testnet/README.md +++ /dev/null @@ -1,32 +0,0 @@ - - -# A tool to launch Sawtooth docker containers - -## Abstract -- Modules to launch Sawtooth docker containers - -## How to build -- Execute the following command, then the docker containers will be launched. - ``` - ./script-start-docker.sh - ``` -- If the following containers appear when you display the container list with the command `docker ps`, it will be fine. - ``` - CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES - 6fe03a6e1716 hyperledger/sawtooth-shell:nightly "bash -c 'sawtooth k…" 4 hours ago Up 4 hours 4004/tcp, 8008/tcp sawtooth-shell-default - c5bbe6ea9904 hyperledger/sawtooth-settings-tp:nightly "settings-tp -vv -C …" 4 hours ago Up 4 hours 4004/tcp sawtooth-settings-tp-default - 016eaa658ed2 hyperledger/sawtooth-intkey-tp-python:nightly "intkey-tp-python -v…" 4 hours ago Up 4 hours 4004/tcp sawtooth-intkey-tp-python-default - 95b77877b672 hyperledger/sawtooth-xo-tp-python:nightly "xo-tp-python -vv -C…" 4 hours ago Up 4 hours 4004/tcp sawtooth-xo-tp-python-default - 1d7ecbc5b84d hyperledger/sawtooth-rest-api:nightly "sawtooth-rest-api -…" 4 hours ago Up 4 hours 4004/tcp, 0.0.0.0:8008->8008/tcp sawtooth-rest-api-default - b44ffa3b385f hyperledger/sawtooth-devmode-engine-rust:nightly "devmode-engine-rust…" 4 hours ago Up 4 hours sawtooth-devmode-engine-rust-default - 8f50d8fbe985 hyperledger/sawtooth-validator:nightly "bash -c 'sawadm key…" 4 hours ago Up 4 hours 0.0.0.0:4004->4004/tcp sawtooth-validator-default - ``` - -## Note -- This directory referenced the minimum files (*.yaml on this repository) for Sawtooth ledger construction from the following repository: - - [Hyperledger/sawtooth-core v1-3 (/docker/compose)](https://github.com/hyperledger/sawtooth-core/tree/1-3/docker/compose) \ No newline at end of file diff --git a/tools/docker/sawtooth-testnet/copy-debs.yaml b/tools/docker/sawtooth-testnet/copy-debs.yaml deleted file mode 100644 index 76a6bb5ad23..00000000000 --- a/tools/docker/sawtooth-testnet/copy-debs.yaml +++ /dev/null @@ -1,134 +0,0 @@ -# Copyright 2018 Cargill Incorporated -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -version: '3.6' - -services: - - settings-tp: - image: sawtooth-settings-tp:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - validator: - image: sawtooth-validator:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - rest-api: - image: sawtooth-rest-api:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - shell: - image: sawtooth-shell:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - admin-tools: - image: sawtooth-admin-tools:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - sawtooth-cli: - image: sawtooth-cli:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - block-info-tp: - image: sawtooth-block-info-tp:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - identity-tp: - image: sawtooth-identity-tp:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - integration: - image: sawtooth-integration:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - smallbank-tp-rust: - image: sawtooth-smallbank-tp-rust:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - smallbank-workload: - image: sawtooth-smallbank-workload:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - intkey-workload: - image: sawtooth-intkey-workload:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " - - sawtooth-meta: - image: sawtooth-meta:${ISOLATION_ID} - volumes: - - ../../build/debs:/build/debs - command: | - bash -c " - cp /tmp/*.deb /build/debs - " diff --git a/tools/docker/sawtooth-testnet/external.yaml b/tools/docker/sawtooth-testnet/external.yaml deleted file mode 100644 index 6fd740170a5..00000000000 --- a/tools/docker/sawtooth-testnet/external.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2018 Cargill Incorporated -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -version: '3.6' - -services: - - apache-basic-auth-proxy: - build: - context: ../ - dockerfile: ./apache-basic-auth-proxy - args: - - http_proxy - - https_proxy - - no_proxy - image: apache-basic-auth-proxy:${ISOLATION_ID} - container_name: apache-basic-auth-proxy-default - - sawtooth-stats-grafana: - build: - context: ../ - dockerfile: ./grafana/sawtooth-stats-grafana - args: - - http_proxy - - https_proxy - - no_proxy - image: sawtooth-stats-grafana:${ISOLATION_ID} - container_name: sawtooth-stats-grafana-default - - sawtooth-stats-influxdb: - build: - context: ../ - dockerfile: ./influxdb/sawtooth-stats-influxdb - args: - - http_proxy - - https_proxy - - no_proxy - image: sawtooth-stats-influxdb:${ISOLATION_ID} - container_name: sawtooth-stats-influxdb-default diff --git a/tools/docker/sawtooth-testnet/run-lint.yaml b/tools/docker/sawtooth-testnet/run-lint.yaml deleted file mode 100644 index f57d105b460..00000000000 --- a/tools/docker/sawtooth-testnet/run-lint.yaml +++ /dev/null @@ -1,57 +0,0 @@ - -# Copyright 2018 Cargill Incorporated -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -version: '3.6' - -services: - - lint-python: - build: - context: ../ - dockerfile: ./lint - args: - - http_proxy - - https_proxy - - no_proxy - image: lint:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - command: run_lint - - lint-rust: - build: - context: ../ - dockerfile: ./lint - args: - - http_proxy - - https_proxy - - no_proxy - image: lint:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - command: run_lint_rust - - lint-validator: - build: - context: ../ - dockerfile: ./lint - args: - - http_proxy - - https_proxy - - no_proxy - image: lint:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - command: run_lint_validator diff --git a/tools/docker/sawtooth-testnet/sawtooth-build.yaml b/tools/docker/sawtooth-testnet/sawtooth-build.yaml deleted file mode 100644 index 7340843b451..00000000000 --- a/tools/docker/sawtooth-testnet/sawtooth-build.yaml +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright 2018 Cargill Incorporated -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -version: '3.6' - -services: - - validator: - build: - context: ../../ - dockerfile: ./validator/Dockerfile - args: - - http_proxy - - https_proxy - - no_proxy - image: sawtooth-validator-local:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - - adm: - build: - context: ../../ - dockerfile: ./adm/Dockerfile - args: - - http_proxy - - https_proxy - - no_proxy - image: sawtooth-adm-local:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - - settings-tp: - build: - context: ../../ - dockerfile: ./families/settings/Dockerfile - args: - - http_proxy - - https_proxy - - no_proxy - image: sawtooth-settings-tp-local:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - - smallbank-rust-tp: - build: - context: ../../ - dockerfile: ./families/smallbank/smallbank_rust/Dockerfile - args: - - http_proxy - - https_proxy - - no_proxy - image: smallbank-rust-tp-local:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - - smallbank-workload: - build: - context: ../../ - dockerfile: ./perf/smallbank_workload/Dockerfile - args: - - http_proxy - - https_proxy - - no_proxy - image: smallbank-workload-local:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - - cli: - build: - context: ../../ - dockerfile: ./cli/Dockerfile - args: - - http_proxy - - https_proxy - - no_proxy - image: sawtooth-cli-local:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - - rest-api: - build: - context: ../../ - dockerfile: ./rest_api/Dockerfile - args: - - http_proxy - - https_proxy - - no_proxy - image: sawtooth-rest-api-local:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - - block-info-tp: - build: - context: ../../ - dockerfile: ./families/block_info/Dockerfile - image: block-info-tp-local:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core - - identity-rust-tp: - build: - context: ../../ - dockerfile: ./families/identity/Dockerfile - image: identity-rust-tp-local:${ISOLATION_ID} - volumes: - - ../../:/project/sawtooth-core diff --git a/tools/docker/sawtooth-testnet/sawtooth-debug.yaml b/tools/docker/sawtooth-testnet/sawtooth-debug.yaml deleted file mode 100644 index 0fa9eca2cca..00000000000 --- a/tools/docker/sawtooth-testnet/sawtooth-debug.yaml +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ------------------------------------------------------------------------------ - -version: "2.1" - -services: - sawtooth-shell: - build: - context: ../.. - dockerfile: docker/sawtooth-debug-python - args: - - http_proxy - - https_proxy - - no_proxy - volumes: - - ../../:/project/sawtooth-core - image: debug-sawtooth-python - container_name: debug-sawtooth-shell - cap_add: - - SYS_PTRACE - entrypoint: | - bash -c " - sed -i 's|#!/usr/bin/env python3|#!/usr/bin/env python3-dbg|' \ - bin/sawtooth-validator && - sed -i 's|#!/usr/bin/env python3|#!/usr/bin/env python3-dbg|' \ - bin/sawtooth-rest-api && - sed -i 's|#!/usr/bin/env python3|#!/usr/bin/env python3-dbg|' \ - bin/sawtooth && - tail -f /dev/null - " - - validator: - build: - context: ../.. - dockerfile: docker/sawtooth-debug-python - args: - - http_proxy - - https_proxy - - no_proxy - volumes: - - ../../:/project/sawtooth-core - image: debug-sawtooth-python - container_name: debug-validator - cap_add: - - SYS_PTRACE - expose: - - 4004 - - 8800 - ports: - - "4050:4004" - command: | - bash -c " - sleep 3 && - if [ ! -f /etc/sawtooth/keys/validator.priv ]; then - sawadm keygen && - sawtooth keygen my_key && - sawset genesis -k /root/.sawtooth/keys/my_key.priv && - sawadm genesis config-genesis.batch - fi; - sawtooth-validator -vv \ - --endpoint tcp://validator:8800 \ - --bind component:tcp://eth0:4004 \ - --bind network:tcp://eth0:8800 - " - - settings-tp: - build: - context: ../.. - dockerfile: docker/sawtooth-debug-python - args: - - http_proxy - - https_proxy - - no_proxy - volumes: - - ../../:/project/sawtooth-core - image: debug-sawtooth-python - container_name: debug-settings-tp - cap_add: - - SYS_PTRACE - depends_on: - - validator - command: settings-tp -vv -C tcp://validator:4004 - - intkey-tp-python: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: intkey-tp-python - depends_on: - - validator - command: intkey-tp-python -vv -C tcp://validator:4004 - - rest-api: - build: - context: ../.. - dockerfile: docker/sawtooth-debug-python - args: - - http_proxy - - https_proxy - - no_proxy - volumes: - - ../../:/project/sawtooth-core - image: debug-sawtooth-python - container_name: debug-rest-api - cap_add: - - SYS_PTRACE - depends_on: - - validator - ports: - - "8008:8008" - command: sawtooth-rest-api -v --connect tcp://validator:4004 --bind rest-api:8008 diff --git a/tools/docker/sawtooth-testnet/sawtooth-default-pbft.yaml b/tools/docker/sawtooth-testnet/sawtooth-default-pbft.yaml deleted file mode 100644 index 53e470ea5a2..00000000000 --- a/tools/docker/sawtooth-testnet/sawtooth-default-pbft.yaml +++ /dev/null @@ -1,454 +0,0 @@ -# Copyright 2019 Cargill Incorporated -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -version: '3.6' - -volumes: - pbft-shared: - -services: - -# -------------=== intkey tp ===------------- - - intkey-tp-0: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-0 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-0:4004 - stop_signal: SIGKILL - - intkey-tp-1: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-1 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-1:4004 - stop_signal: SIGKILL - - intkey-tp-2: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-2 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-2:4004 - stop_signal: SIGKILL - - intkey-tp-3: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-3 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-3:4004 - stop_signal: SIGKILL - - intkey-tp-4: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-4 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-4:4004 - stop_signal: SIGKILL - -# -------------=== rest api ===------------- - - rest-api-0: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-0 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-0:4004 \ - --bind rest-api-0:8008 - " - stop_signal: SIGKILL - - rest-api-1: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-1 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-1:4004 \ - --bind rest-api-1:8008 - " - stop_signal: SIGKILL - - rest-api-2: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-2 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-2:4004 \ - --bind rest-api-2:8008 - " - stop_signal: SIGKILL - - rest-api-3: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-3 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-3:4004 \ - --bind rest-api-3:8008 - " - stop_signal: SIGKILL - - rest-api-4: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-4 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-4:4004 \ - --bind rest-api-4:8008 - " - stop_signal: SIGKILL - -# -------------=== settings tp ===------------- - - settings-tp-0: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-0 - expose: - - 4004 - command: settings-tp -C tcp://validator-0:4004 - stop_signal: SIGKILL - - settings-tp-1: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-1 - expose: - - 4004 - command: settings-tp -C tcp://validator-1:4004 - stop_signal: SIGKILL - - settings-tp-2: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-2 - expose: - - 4004 - command: settings-tp -C tcp://validator-2:4004 - stop_signal: SIGKILL - - settings-tp-3: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-3 - expose: - - 4004 - command: settings-tp -C tcp://validator-3:4004 - stop_signal: SIGKILL - - settings-tp-4: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-4 - expose: - - 4004 - command: settings-tp -C tcp://validator-4:4004 - stop_signal: SIGKILL - -# -------------=== shell ===------------- - - shell: - image: hyperledger/sawtooth-shell:nightly - container_name: sawtooth-shell-default - volumes: - - pbft-shared:/pbft-shared - command: | - bash -c " - sawtooth keygen - tail -f /dev/null - " - stop_signal: SIGKILL - -# -------------=== validators ===------------- - - validator-0: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-0 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - pbft-shared:/pbft-shared - command: | - bash -c " - if [ -e /pbft-shared/validators/validator-0.priv ]; then - cp /pbft-shared/validators/validator-0.pub /etc/sawtooth/keys/validator.pub - cp /pbft-shared/validators/validator-0.priv /etc/sawtooth/keys/validator.priv - fi && - if [ ! -e /etc/sawtooth/keys/validator.priv ]; then - sawadm keygen - mkdir -p /pbft-shared/validators || true - cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-0.pub - cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-0.priv - fi && - if [ ! -e config-genesis.batch ]; then - sawset genesis -k /etc/sawtooth/keys/validator.priv -o config-genesis.batch - fi && - while [[ ! -f /pbft-shared/validators/validator-1.pub || \ - ! -f /pbft-shared/validators/validator-2.pub || \ - ! -f /pbft-shared/validators/validator-3.pub || \ - ! -f /pbft-shared/validators/validator-4.pub ]]; - do sleep 1; done - echo sawtooth.consensus.pbft.members=\\['\"'$$(cat /pbft-shared/validators/validator-0.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-1.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-2.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-3.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-4.pub)'\"'\\] && - if [ ! -e config.batch ]; then - sawset proposal create \ - -k /etc/sawtooth/keys/validator.priv \ - sawtooth.consensus.algorithm.name=pbft \ - sawtooth.consensus.algorithm.version=1.0 \ - sawtooth.consensus.pbft.members=\\['\"'$$(cat /pbft-shared/validators/validator-0.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-1.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-2.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-3.pub)'\"','\"'$$(cat /pbft-shared/validators/validator-4.pub)'\"'\\] \ - sawtooth.publisher.max_batches_per_block=1200 \ - -o config.batch - fi && - if [ ! -e /var/lib/sawtooth/genesis.batch ]; then - sawadm genesis config-genesis.batch config.batch - fi && - if [ ! -e /root/.sawtooth/keys/my_key.priv ]; then - sawtooth keygen my_key - fi && - sawtooth-validator -vv \ - --endpoint tcp://validator-0:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --bind network:tcp://eth0:8800 \ - --scheduler parallel \ - --peering static \ - --maximum-peer-connectivity 10000 - " - - validator-1: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-1 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - pbft-shared:/pbft-shared - command: | - bash -c " - if [ -e /pbft-shared/validators/validator-1.priv ]; then - cp /pbft-shared/validators/validator-1.pub /etc/sawtooth/keys/validator.pub - cp /pbft-shared/validators/validator-1.priv /etc/sawtooth/keys/validator.priv - fi && - if [ ! -e /etc/sawtooth/keys/validator.priv ]; then - sawadm keygen - mkdir -p /pbft-shared/validators || true - cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-1.pub - cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-1.priv - fi && - sawtooth keygen my_key && - sawtooth-validator -vv \ - --endpoint tcp://validator-1:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --bind network:tcp://eth0:8800 \ - --scheduler parallel \ - --peering static \ - --maximum-peer-connectivity 10000 \ - --peers tcp://validator-0:8800 - " - - validator-2: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-2 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - pbft-shared:/pbft-shared - command: | - bash -c " - if [ -e /pbft-shared/validators/validator-2.priv ]; then - cp /pbft-shared/validators/validator-2.pub /etc/sawtooth/keys/validator.pub - cp /pbft-shared/validators/validator-2.priv /etc/sawtooth/keys/validator.priv - fi && - if [ ! -e /etc/sawtooth/keys/validator.priv ]; then - sawadm keygen - mkdir -p /pbft-shared/validators || true - cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-2.pub - cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-2.priv - fi && - sawtooth keygen my_key && - sawtooth-validator -vv \ - --endpoint tcp://validator-2:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --bind network:tcp://eth0:8800 \ - --scheduler parallel \ - --peering static \ - --maximum-peer-connectivity 10000 \ - --peers tcp://validator-0:8800 \ - --peers tcp://validator-1:8800 - " - - validator-3: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-3 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - pbft-shared:/pbft-shared - command: | - bash -c " - if [ -e /pbft-shared/validators/validator-3.priv ]; then - cp /pbft-shared/validators/validator-3.pub /etc/sawtooth/keys/validator.pub - cp /pbft-shared/validators/validator-3.priv /etc/sawtooth/keys/validator.priv - fi && - if [ ! -e /etc/sawtooth/keys/validator.priv ]; then - sawadm keygen - mkdir -p /pbft-shared/validators || true - cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-3.pub - cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-3.priv - fi && - sawtooth keygen my_key && - sawtooth-validator -vv \ - --endpoint tcp://validator-3:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --bind network:tcp://eth0:8800 \ - --scheduler parallel \ - --peering static \ - --maximum-peer-connectivity 10000 \ - --peers tcp://validator-0:8800 \ - --peers tcp://validator-1:8800 \ - --peers tcp://validator-2:8800 - " - - validator-4: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-4 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - pbft-shared:/pbft-shared - command: | - bash -c " - if [ -e /pbft-shared/validators/validator-4.priv ]; then - cp /pbft-shared/validators/validator-4.pub /etc/sawtooth/keys/validator.pub - cp /pbft-shared/validators/validator-4.priv /etc/sawtooth/keys/validator.priv - fi && - if [ ! -e /etc/sawtooth/keys/validator.priv ]; then - sawadm keygen - mkdir -p /pbft-shared/validators || true - cp /etc/sawtooth/keys/validator.pub /pbft-shared/validators/validator-4.pub - cp /etc/sawtooth/keys/validator.priv /pbft-shared/validators/validator-4.priv - fi && - sawtooth keygen my_key && - sawtooth-validator -vv \ - --endpoint tcp://validator-4:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --bind network:tcp://eth0:8800 \ - --scheduler parallel \ - --peering static \ - --maximum-peer-connectivity 10000 \ - --peers tcp://validator-0:8800 \ - --peers tcp://validator-1:8800 \ - --peers tcp://validator-2:8800 \ - --peers tcp://validator-3:8800 - " - -# -------------=== pbft engines ===------------- - - pbft-0: - image: hyperledger/sawtooth-pbft-engine:nightly - container_name: sawtooth-pbft-engine-default-0 - command: pbft-engine -vv --connect tcp://validator-0:5050 - stop_signal: SIGKILL - - pbft-1: - image: hyperledger/sawtooth-pbft-engine:nightly - container_name: sawtooth-pbft-engine-default-1 - command: pbft-engine -vv --connect tcp://validator-1:5050 - stop_signal: SIGKILL - - pbft-2: - image: hyperledger/sawtooth-pbft-engine:nightly - container_name: sawtooth-pbft-engine-default-2 - command: pbft-engine -vv --connect tcp://validator-2:5050 - stop_signal: SIGKILL - - pbft-3: - image: hyperledger/sawtooth-pbft-engine:nightly - container_name: sawtooth-pbft-engine-default-3 - command: pbft-engine -vv --connect tcp://validator-3:5050 - stop_signal: SIGKILL - - pbft-4: - image: hyperledger/sawtooth-pbft-engine:nightly - container_name: sawtooth-pbft-engine-default-4 - command: pbft-engine -vv --connect tcp://validator-4:5050 - stop_signal: SIGKILL - -# -------------=== xo tps ===------------- - - xo-tp-0: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-0 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-0:4004 - stop_signal: SIGKILL - - xo-tp-1: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-1 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-1:4004 - stop_signal: SIGKILL - - xo-tp-2: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-2 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-2:4004 - stop_signal: SIGKILL - - xo-tp-3: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-3 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-3:4004 - stop_signal: SIGKILL - - xo-tp-4: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-4 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-4:4004 - stop_signal: SIGKILL diff --git a/tools/docker/sawtooth-testnet/sawtooth-default-poet.yaml b/tools/docker/sawtooth-testnet/sawtooth-default-poet.yaml deleted file mode 100644 index 66ecbf3cd29..00000000000 --- a/tools/docker/sawtooth-testnet/sawtooth-default-poet.yaml +++ /dev/null @@ -1,500 +0,0 @@ -# Copyright 2018 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ------------------------------------------------------------------------------ - -version: "2.1" - -volumes: - poet-shared: - -services: - shell: - image: hyperledger/sawtooth-shell:nightly - container_name: sawtooth-shell-default - entrypoint: "bash -c \"\ - sawtooth keygen && \ - tail -f /dev/null \ - \"" - - validator-0: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-0 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - poet-shared:/poet-shared - command: "bash -c \"\ - sawadm keygen --force && \ - mkdir -p /poet-shared/validator-0 || true && \ - cp -a /etc/sawtooth/keys /poet-shared/validator-0/ && \ - while [ ! -f /poet-shared/poet-enclave-measurement ]; do sleep 1; done && \ - while [ ! -f /poet-shared/poet-enclave-basename ]; do sleep 1; done && \ - while [ ! -f /poet-shared/poet.batch ]; do sleep 1; done && \ - cp /poet-shared/poet.batch / && \ - sawset genesis \ - -k /etc/sawtooth/keys/validator.priv \ - -o config-genesis.batch && \ - sawset proposal create \ - -k /etc/sawtooth/keys/validator.priv \ - sawtooth.consensus.algorithm.name=PoET \ - sawtooth.consensus.algorithm.version=0.1 \ - sawtooth.poet.report_public_key_pem=\ - \\\"$$(cat /poet-shared/simulator_rk_pub.pem)\\\" \ - sawtooth.poet.valid_enclave_measurements=$$(cat /poet-shared/poet-enclave-measurement) \ - sawtooth.poet.valid_enclave_basenames=$$(cat /poet-shared/poet-enclave-basename) \ - -o config.batch && \ - sawset proposal create \ - -k /etc/sawtooth/keys/validator.priv \ - sawtooth.poet.target_wait_time=5 \ - sawtooth.poet.initial_wait_time=25 \ - sawtooth.publisher.max_batches_per_block=100 \ - -o poet-settings.batch && \ - sawadm genesis \ - config-genesis.batch config.batch poet.batch poet-settings.batch && \ - sawtooth-validator -v \ - --bind network:tcp://eth0:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --peering static \ - --endpoint tcp://validator-0:8800 \ - --scheduler parallel \ - --network-auth trust - \"" - environment: - PYTHONPATH: "/project/sawtooth-core/consensus/poet/common:\ - /project/sawtooth-core/consensus/poet/simulator:\ - /project/sawtooth-core/consensus/poet/core" - stop_signal: SIGKILL - - validator-1: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-1 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - poet-shared:/poet-shared - command: | - bash -c " - sawadm keygen --force && \ - mkdir -p /poet-shared/validator-1 || true && \ - cp -a /etc/sawtooth/keys /poet-shared/validator-1/ && \ - sawtooth-validator -v \ - --bind network:tcp://eth0:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --peering static \ - --endpoint tcp://validator-1:8800 \ - --peers tcp://validator-0:8800 \ - --scheduler parallel \ - --network-auth trust - " - environment: - PYTHONPATH: "/project/sawtooth-core/consensus/poet/common:\ - /project/sawtooth-core/consensus/poet/simulator:\ - /project/sawtooth-core/consensus/poet/core" - stop_signal: SIGKILL - - validator-2: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-2 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - poet-shared:/poet-shared - command: | - bash -c " - sawadm keygen --force && \ - mkdir -p /poet-shared/validator-2 && \ - cp -a /etc/sawtooth/keys /poet-shared/validator-2/ && \ - sawtooth-validator -v \ - --bind network:tcp://eth0:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --peering static \ - --endpoint tcp://validator-2:8800 \ - --peers tcp://validator-0:8800,tcp://validator-1:8800 \ - --scheduler parallel \ - --network-auth trust - " - environment: - PYTHONPATH: "/project/sawtooth-core/consensus/poet/common:\ - /project/sawtooth-core/consensus/poet/simulator:\ - /project/sawtooth-core/consensus/poet/core" - stop_signal: SIGKILL - - validator-3: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-3 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - poet-shared:/poet-shared - command: | - bash -c " - sawadm keygen --force && \ - mkdir -p /poet-shared/validator-3 && \ - cp -a /etc/sawtooth/keys /poet-shared/validator-3/ && \ - sawtooth-validator -v \ - --bind network:tcp://eth0:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --peering static \ - --endpoint tcp://validator-3:8800 \ - --peers tcp://validator-0:8800,tcp://validator-1:8800,tcp://validator-2:8800 \ - --scheduler parallel \ - --network-auth trust - " - environment: - PYTHONPATH: "/project/sawtooth-core/consensus/poet/common:\ - /project/sawtooth-core/consensus/poet/simulator:\ - /project/sawtooth-core/consensus/poet/core" - stop_signal: SIGKILL - - validator-4: - image: hyperledger/sawtooth-validator:nightly - container_name: sawtooth-validator-default-4 - expose: - - 4004 - - 5050 - - 8800 - volumes: - - poet-shared:/poet-shared - command: | - bash -c " - sawadm keygen --force && \ - mkdir -p /poet-shared/validator-4 && \ - cp -a /etc/sawtooth/keys /poet-shared/validator-4/ && \ - sawtooth-validator -v \ - --bind network:tcp://eth0:8800 \ - --bind component:tcp://eth0:4004 \ - --bind consensus:tcp://eth0:5050 \ - --peering static \ - --endpoint tcp://validator-4:8800 \ - --peers tcp://validator-0:8800,tcp://validator-1:8800,tcp://validator-2:8800,tcp://validator-3:8800 \ - --scheduler parallel \ - --network-auth trust - " - environment: - PYTHONPATH: "/project/sawtooth-core/consensus/poet/common:\ - /project/sawtooth-core/consensus/poet/simulator:\ - /project/sawtooth-core/consensus/poet/core" - stop_signal: SIGKILL - - rest-api-0: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-0 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-0:4004 \ - --bind rest-api-0:8008 - " - stop_signal: SIGKILL - - rest-api-1: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-1 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-1:4004 \ - --bind rest-api-1:8008 - " - stop_signal: SIGKILL - - rest-api-2: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-2 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-2:4004 \ - --bind rest-api-2:8008 - " - stop_signal: SIGKILL - - rest-api-3: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-3 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-3:4004 \ - --bind rest-api-3:8008 - " - stop_signal: SIGKILL - - rest-api-4: - image: hyperledger/sawtooth-rest-api:nightly - container_name: sawtooth-rest-api-default-4 - expose: - - 8008 - command: | - bash -c " - sawtooth-rest-api \ - --connect tcp://validator-4:4004 \ - --bind rest-api-4:8008 - " - stop_signal: SIGKILL - - intkey-tp-0: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-0 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-0:4004 - stop_signal: SIGKILL - - intkey-tp-1: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-1 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-1:4004 - stop_signal: SIGKILL - - intkey-tp-2: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-2 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-2:4004 - stop_signal: SIGKILL - - intkey-tp-3: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-3 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-3:4004 - stop_signal: SIGKILL - - intkey-tp-4: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-default-4 - expose: - - 4004 - command: intkey-tp-python -C tcp://validator-4:4004 - stop_signal: SIGKILL - - xo-tp-0: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-0 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-0:4004 - stop_signal: SIGKILL - - xo-tp-1: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-1 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-1:4004 - stop_signal: SIGKILL - - xo-tp-2: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-2 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-2:4004 - stop_signal: SIGKILL - - xo-tp-3: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-3 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-3:4004 - stop_signal: SIGKILL - - xo-tp-4: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-default-4 - expose: - - 4004 - command: xo-tp-python -vv -C tcp://validator-4:4004 - stop_signal: SIGKILL - - settings-tp-0: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-0 - expose: - - 4004 - command: settings-tp -v -C tcp://validator-0:4004 - stop_signal: SIGKILL - - settings-tp-1: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-1 - expose: - - 4004 - command: settings-tp -v -C tcp://validator-1:4004 - stop_signal: SIGKILL - - settings-tp-2: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-2 - expose: - - 4004 - command: settings-tp -v -C tcp://validator-2:4004 - stop_signal: SIGKILL - - settings-tp-3: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-3 - expose: - - 4004 - command: settings-tp -v -C tcp://validator-3:4004 - stop_signal: SIGKILL - - settings-tp-4: - image: hyperledger/sawtooth-settings-tp:nightly - container_name: sawtooth-settings-tp-default-4 - expose: - - 4004 - command: settings-tp -v -C tcp://validator-4:4004 - stop_signal: SIGKILL - - poet-engine-0: - image: hyperledger/sawtooth-poet-engine:nightly - container_name: sawtooth-poet-engine-0 - volumes: - - poet-shared:/poet-shared - command: "bash -c \"\ - if [ ! -f /poet-shared/poet-enclave-measurement ]; then \ - poet enclave measurement >> /poet-shared/poet-enclave-measurement; \ - fi && \ - if [ ! -f /poet-shared/poet-enclave-basename ]; then \ - poet enclave basename >> /poet-shared/poet-enclave-basename; \ - fi && \ - if [ ! -f /poet-shared/simulator_rk_pub.pem ]; then \ - cp /etc/sawtooth/simulator_rk_pub.pem /poet-shared; \ - fi && \ - while [ ! -f /poet-shared/validator-0/keys/validator.priv ]; do sleep 1; done && \ - cp -a /poet-shared/validator-0/keys /etc/sawtooth && \ - poet registration create -k /etc/sawtooth/keys/validator.priv -o /poet-shared/poet.batch && \ - poet-engine -C tcp://validator-0:5050 --component tcp://validator-0:4004 \ - \"" - - poet-engine-1: - image: hyperledger/sawtooth-poet-engine:nightly - container_name: sawtooth-poet-engine-1 - volumes: - - poet-shared:/poet-shared - command: "bash -c \"\ - while [ ! -f /poet-shared/validator-1/keys/validator.priv ]; do sleep 1; done && \ - cp -a /poet-shared/validator-1/keys /etc/sawtooth && \ - poet-engine -C tcp://validator-1:5050 --component tcp://validator-1:4004 \ - \"" - - poet-engine-2: - image: hyperledger/sawtooth-poet-engine:nightly - container_name: sawtooth-poet-engine-2 - volumes: - - poet-shared:/poet-shared - command: "bash -c \"\ - while [ ! -f /poet-shared/validator-2/keys/validator.priv ]; do sleep 1; done && \ - cp -a /poet-shared/validator-2/keys /etc/sawtooth && \ - poet-engine -C tcp://validator-2:5050 --component tcp://validator-2:4004 \ - \"" - - poet-engine-3: - image: hyperledger/sawtooth-poet-engine:nightly - container_name: sawtooth-poet-engine-3 - volumes: - - poet-shared:/poet-shared - command: "bash -c \"\ - while [ ! -f /poet-shared/validator-3/keys/validator.priv ]; do sleep 1; done && \ - cp -a /poet-shared/validator-3/keys /etc/sawtooth && \ - poet-engine -C tcp://validator-3:5050 --component tcp://validator-3:4004 \ - \"" - - poet-engine-4: - image: hyperledger/sawtooth-poet-engine:nightly - container_name: sawtooth-poet-engine-4 - volumes: - - poet-shared:/poet-shared - command: "bash -c \"\ - while [ ! -f /poet-shared/validator-4/keys/validator.priv ]; do sleep 1; done && \ - cp -a /poet-shared/validator-4/keys /etc/sawtooth && \ - poet-engine -C tcp://validator-4:5050 --component tcp://validator-4:4004 \ - \"" - - poet-validator-registry-tp-0: - image: hyperledger/sawtooth-poet-validator-registry-tp:nightly - container_name: sawtooth-poet-validator-registry-tp-0 - expose: - - 4004 - command: poet-validator-registry-tp -C tcp://validator-0:4004 - environment: - PYTHONPATH: /project/sawtooth-core/consensus/poet/common - stop_signal: SIGKILL - - poet-validator-registry-tp-1: - image: hyperledger/sawtooth-poet-validator-registry-tp:nightly - container_name: sawtooth-poet-validator-registry-tp-1 - expose: - - 4004 - command: poet-validator-registry-tp -C tcp://validator-1:4004 - environment: - PYTHONPATH: /project/sawtooth-core/consensus/poet/common - stop_signal: SIGKILL - - poet-validator-registry-tp-2: - image: hyperledger/sawtooth-poet-validator-registry-tp:nightly - container_name: sawtooth-poet-validator-registry-tp-2 - expose: - - 4004 - command: poet-validator-registry-tp -C tcp://validator-2:4004 - environment: - PYTHONPATH: /project/sawtooth-core/consensus/poet/common - stop_signal: SIGKILL - - poet-validator-registry-tp-3: - image: hyperledger/sawtooth-poet-validator-registry-tp:nightly - container_name: sawtooth-poet-validator-registry-tp-3 - expose: - - 4004 - command: poet-validator-registry-tp -C tcp://validator-3:4004 - environment: - PYTHONPATH: /project/sawtooth-core/consensus/poet/common - stop_signal: SIGKILL - - poet-validator-registry-tp-4: - image: hyperledger/sawtooth-poet-validator-registry-tp:nightly - container_name: sawtooth-poet-validator-registry-tp-4 - expose: - - 4004 - command: poet-validator-registry-tp -C tcp://validator-4:4004 - environment: - PYTHONPATH: /project/sawtooth-core/consensus/poet/common - stop_signal: SIGKILL diff --git a/tools/docker/sawtooth-testnet/sawtooth-local.yaml b/tools/docker/sawtooth-testnet/sawtooth-local.yaml deleted file mode 100644 index 61109321fde..00000000000 --- a/tools/docker/sawtooth-testnet/sawtooth-local.yaml +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ------------------------------------------------------------------------------ - -version: "2.1" - -services: - - settings-tp: - image: sawtooth-settings-tp:latest - container_name: sawtooth-settings-tp-local - volumes: - - ../../:/project/sawtooth-core - depends_on: - - validator - command: settings-tp -vv -C tcp://validator:4004 - stop_signal: SIGKILL - - intkey-tp-python: - image: hyperledger/sawtooth-intkey-tp-python:nightly - container_name: sawtooth-intkey-tp-python-local - depends_on: - - validator - command: intkey-tp-python -vv -C tcp://validator:4004 - stop_signal: SIGKILL - - xo-tp-python: - image: hyperledger/sawtooth-xo-tp-python:nightly - container_name: sawtooth-xo-tp-python-local - depends_on: - - validator - command: xo-tp-python -vv -C tcp://validator:4004 - stop_signal: SIGKILL - - validator: - image: sawtooth-validator:latest - container_name: sawtooth-validator-local - volumes: - - ../../:/project/sawtooth-core - expose: - - 4004 - - 8800 - ports: - - "4004:4004" - # start the validator with an empty genesis batch - command: "bash -c \"\ - sawadm keygen && \ - sawadm genesis && \ - sawtooth-validator -vv \ - --endpoint tcp://validator:8800 \ - --bind component:tcp://eth0:4004 \ - --bind network:tcp://eth0:8800 \ - \"" - stop_signal: SIGKILL - - rest-api: - image: sawtooth-rest-api:latest - container_name: sawtooth-rest-api-local - volumes: - - ../../:/project/sawtooth-core - ports: - - "8008:8008" - depends_on: - - validator - command: sawtooth-rest-api -v --connect tcp://validator:4004 --bind rest-api:8008 - stop_signal: SIGKILL - - client: - image: sawtooth-dev-python:latest - container_name: sawtooth-client-local - volumes: - - ../../:/project/sawtooth-core - depends_on: - - rest-api - entrypoint: "bash -c \"\ - sawtooth keygen && \ - tail -f /dev/null \ - \"" diff --git a/tools/docker/sawtooth-testnet/script-start-docker.sh b/tools/docker/sawtooth-testnet/script-start-docker.sh deleted file mode 100755 index 345178e7862..00000000000 --- a/tools/docker/sawtooth-testnet/script-start-docker.sh +++ /dev/null @@ -1,3 +0,0 @@ -echo "[process] start docker environment for Sawtooth testnet" -docker network create sawtooth_net -docker-compose -f sawtooth-default.yaml up -d \ No newline at end of file diff --git a/tools/docker/sawtooth-testnet/smallbank-local-mounted.yaml b/tools/docker/sawtooth-testnet/smallbank-local-mounted.yaml deleted file mode 100644 index d4c6956db2f..00000000000 --- a/tools/docker/sawtooth-testnet/smallbank-local-mounted.yaml +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ------------------------------------------------------------------------------ - -version: "2.1" - -services: - - settings-tp: - image: sawtooth-settings-tp:latest - volumes: - - ../../:/project/sawtooth-core - container_name: sawtooth-settings-tp-default - depends_on: - - validator - command: settings-tp -vv --connect tcp://validator:4004 - - smallbank-tp-rust: - image: sawtooth-smallbank-tp-rust:latest - container_name: sawtooth-smallbank-tp-rust-default - volumes: - - ../../:/project/sawtooth-core - depends_on: - - validator - command: smallbank_rust -vv -C tcp://validator:4004 - - validator: - image: sawtooth-validator-mounted:latest - container_name: sawtooth-validator-mounted - volumes: - - ../../:/project/sawtooth-core - expose: - - 4004 - ports: - - "4004:4004" - command: "bash -c \"\ - (telegraf &) && \ - sawadm keygen && \ - sawtooth keygen && \ - sawset genesis && \ - sawadm genesis config-genesis.batch && \ - sawtooth-validator -vv \ - --endpoint tcp://validator:8800 \ - --bind component:tcp://eth0:4004 \ - --bind network:tcp://eth0:8800 \ - --opentsdb-url http://influxdb:8086 \ - --opentsdb-db metrics - \"" - - rest-api: - image: sawtooth-rest-api:latest - container_name: sawtooth-rest-api-default - volumes: - - ../../:/project/sawtooth-core - expose: - - 8008 - ports: - - "8008:8008" - depends_on: - - validator - command: sawtooth-rest-api -v --connect tcp://validator:4004 --bind rest-api:8008 --opentsdb-url http://influxdb:8086 --opentsdb-db metrics - - influxdb: - image: sawtooth-stats-influxdb:latest - container_name: sawtooth-stats-influxdb-default - ports: - - "8086:8086" - stop_signal: SIGKILL - - grafana: - image: sawtooth-stats-grafana:latest - container_name: sawtooth-stats-grafana-default - ports: - - "3000:3000" - volumes: - - ../../:/project/sawtooth-core - stop_signal: SIGKILL