From 4d061b4c37f53f24a225cb5568e0cf2f8a9d623d Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 22 Jan 2020 09:58:33 +0100 Subject: [PATCH] Add some sample scripts to run gaiad for tests --- scripts/cosm/.gaiacli/config/config.toml | 3 + scripts/cosm/.gaiad/config/addrbook.json | 4 + scripts/cosm/.gaiad/config/app.toml | 24 ++ scripts/cosm/.gaiad/config/config.toml | 312 ++++++++++++++++++ scripts/cosm/.gaiad/config/genesis.json | 196 +++++++++++ ...aedddd9442bcf16641858ca85837f27997d0d.json | 39 +++ scripts/cosm/.gaiad/config/node_key.json | 6 + .../.gaiad/config/priv_validator_key.json | 11 + scripts/cosm/.gitignore | 2 + scripts/cosm/README.md | 80 +++++ scripts/cosm/cli.sh | 21 ++ .../cosm/priv_validator_state.template.json | 1 + scripts/cosm/start.sh | 49 +++ scripts/cosm/stop.sh | 8 + scripts/iov_faucet_start.sh | 25 ++ scripts/iov_faucet_stop.sh | 9 + 16 files changed, 790 insertions(+) create mode 100644 scripts/cosm/.gaiacli/config/config.toml create mode 100644 scripts/cosm/.gaiad/config/addrbook.json create mode 100644 scripts/cosm/.gaiad/config/app.toml create mode 100644 scripts/cosm/.gaiad/config/config.toml create mode 100644 scripts/cosm/.gaiad/config/genesis.json create mode 100644 scripts/cosm/.gaiad/config/gentx/gentx-223aedddd9442bcf16641858ca85837f27997d0d.json create mode 100644 scripts/cosm/.gaiad/config/node_key.json create mode 100644 scripts/cosm/.gaiad/config/priv_validator_key.json create mode 100644 scripts/cosm/.gitignore create mode 100644 scripts/cosm/README.md create mode 100755 scripts/cosm/cli.sh create mode 100644 scripts/cosm/priv_validator_state.template.json create mode 100755 scripts/cosm/start.sh create mode 100755 scripts/cosm/stop.sh create mode 100755 scripts/iov_faucet_start.sh create mode 100755 scripts/iov_faucet_stop.sh diff --git a/scripts/cosm/.gaiacli/config/config.toml b/scripts/cosm/.gaiacli/config/config.toml new file mode 100644 index 00000000..a87339da --- /dev/null +++ b/scripts/cosm/.gaiacli/config/config.toml @@ -0,0 +1,3 @@ +chain-id = "testing" +node = "tcp://localhost:46657" +trust-node = true diff --git a/scripts/cosm/.gaiad/config/addrbook.json b/scripts/cosm/.gaiad/config/addrbook.json new file mode 100644 index 00000000..852eb97d --- /dev/null +++ b/scripts/cosm/.gaiad/config/addrbook.json @@ -0,0 +1,4 @@ +{ + "key": "84524d4c173831437f628f5d", + "addrs": [] +} \ No newline at end of file diff --git a/scripts/cosm/.gaiad/config/app.toml b/scripts/cosm/.gaiad/config/app.toml new file mode 100644 index 00000000..5b42ddfe --- /dev/null +++ b/scripts/cosm/.gaiad/config/app.toml @@ -0,0 +1,24 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +##### main base config options ##### + +# The minimum gas prices a validator is willing to accept for processing a +# transaction. A transaction's fees must meet the minimum of any denomination +# specified in this config (e.g. 0.25token1;0.0001token2). +minimum-gas-prices = "" + +# HaltHeight contains a non-zero block height at which a node will gracefully +# halt and shutdown that can be used to assist upgrades and testing. +# +# Note: State will not be committed on the corresponding height and any logs +# indicating such can be safely ignored. +halt-height = 0 + +# HaltTime contains a non-zero minimum block time (in Unix seconds) at which +# a node will gracefully halt and shutdown that can be used to assist upgrades +# and testing. +# +# Note: State will not be committed on the corresponding height and any logs +# indicating such can be safely ignored. +halt-time = 0 diff --git a/scripts/cosm/.gaiad/config/config.toml b/scripts/cosm/.gaiad/config/config.toml new file mode 100644 index 00000000..061e5b40 --- /dev/null +++ b/scripts/cosm/.gaiad/config/config.toml @@ -0,0 +1,312 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +##### main base config options ##### + +# TCP or UNIX socket address of the ABCI application, +# or the name of an ABCI application compiled in with the Tendermint binary +proxy_app = "tcp://127.0.0.1:26658" + +# A custom human readable name for this node +moniker = "testing" + +# If this node is many blocks behind the tip of the chain, FastSync +# allows them to catchup quickly by downloading blocks in parallel +# and verifying their commits +fast_sync = true + +# Database backend: goleveldb | cleveldb | boltdb +# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# - pure go +# - stable +# * cleveldb (uses levigo wrapper) +# - fast +# - requires gcc +# - use cleveldb build tag (go build -tags cleveldb) +# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) +# - EXPERIMENTAL +# - may be faster is some use-cases (random reads - indexer) +# - use boltdb build tag (go build -tags boltdb) +db_backend = "goleveldb" + +# Database directory +db_dir = "data" + +# Output level for logging, including package level options +log_level = "main:info,state:info,*:error" + +# Output format: 'plain' (colored text) or 'json' +log_format = "plain" + +##### additional base config options ##### + +# Path to the JSON file containing the initial validator set and other meta data +genesis_file = "config/genesis.json" + +# Path to the JSON file containing the private key to use as a validator in the consensus protocol +priv_validator_key_file = "config/priv_validator_key.json" + +# Path to the JSON file containing the last sign state of a validator +priv_validator_state_file = "data/priv_validator_state.json" + +# TCP or UNIX socket address for Tendermint to listen on for +# connections from an external PrivValidator process +priv_validator_laddr = "" + +# Path to the JSON file containing the private key to use for node authentication in the p2p protocol +node_key_file = "config/node_key.json" + +# Mechanism to connect to the ABCI application: socket | grpc +abci = "socket" + +# TCP or UNIX socket address for the profiling server to listen on +prof_laddr = "localhost:6060" + +# If true, query the ABCI app on connecting to a new peer +# so the app can decide if we should keep the connection or not +filter_peers = false + +##### advanced configuration options ##### + +##### rpc server configuration options ##### +[rpc] + +# TCP or UNIX socket address for the RPC server to listen on +laddr = "tcp://127.0.0.1:26657" + +# A list of origins a cross-domain request can be executed from +# Default value '[]' disables cors support +# Use '["*"]' to allow any origin +cors_allowed_origins = [] + +# A list of methods the client is allowed to use with cross-domain requests +cors_allowed_methods = ["HEAD", "GET", "POST", ] + +# A list of non simple headers the client is allowed to use with cross-domain requests +cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] + +# TCP or UNIX socket address for the gRPC server to listen on +# NOTE: This server only supports /broadcast_tx_commit +grpc_laddr = "" + +# Maximum number of simultaneous connections. +# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +grpc_max_open_connections = 900 + +# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool +unsafe = false + +# Maximum number of simultaneous connections (including WebSocket). +# Does not include gRPC connections. See grpc_max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +max_open_connections = 900 + +# Maximum number of unique clientIDs that can /subscribe +# If you're using /broadcast_tx_commit, set to the estimated maximum number +# of broadcast_tx_commit calls per block. +max_subscription_clients = 100 + +# Maximum number of unique queries a given client can /subscribe to +# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to +# the estimated # maximum number of broadcast_tx_commit calls per block. +max_subscriptions_per_client = 5 + +# How long to wait for a tx to be committed during /broadcast_tx_commit. +# WARNING: Using a value larger than 10s will result in increasing the +# global HTTP write timeout, which applies to all connections and endpoints. +# See https://github.com/tendermint/tendermint/issues/3435 +timeout_broadcast_tx_commit = "10s" + +# Maximum size of request body, in bytes +max_body_bytes = 1000000 + +# Maximum size of request header, in bytes +max_header_bytes = 1048576 + +# The path to a file containing certificate that is used to create the HTTPS server. +# Migth be either absolute path or path related to tendermint's config directory. +# If the certificate is signed by a certificate authority, +# the certFile should be the concatenation of the server's certificate, any intermediates, +# and the CA's certificate. +# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run. +tls_cert_file = "" + +# The path to a file containing matching private key that is used to create the HTTPS server. +# Migth be either absolute path or path related to tendermint's config directory. +# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run. +tls_key_file = "" + +##### peer to peer configuration options ##### +[p2p] + +# Address to listen for incoming connections +laddr = "tcp://0.0.0.0:26656" + +# Address to advertise to peers for them to dial +# If empty, will use the same port as the laddr, +# and will introspect on the listener or use UPnP +# to figure out the address. +external_address = "" + +# Comma separated list of seed nodes to connect to +seeds = "" + +# Comma separated list of nodes to keep persistent connections to +persistent_peers = "" + +# UPNP port forwarding +upnp = false + +# Path to address book +addr_book_file = "config/addrbook.json" + +# Set true for strict address routability rules +# Set false for private or local networks +addr_book_strict = true + +# Maximum number of inbound peers +max_num_inbound_peers = 40 + +# Maximum number of outbound peers to connect to, excluding persistent peers +max_num_outbound_peers = 10 + +# Time to wait before flushing messages out on the connection +flush_throttle_timeout = "100ms" + +# Maximum size of a message packet payload, in bytes +max_packet_msg_payload_size = 1024 + +# Rate at which packets can be sent, in bytes/second +send_rate = 5120000 + +# Rate at which packets can be received, in bytes/second +recv_rate = 5120000 + +# Set true to enable the peer-exchange reactor +pex = true + +# Seed mode, in which node constantly crawls the network and looks for +# peers. If another node asks it for addresses, it responds and disconnects. +# +# Does not work if the peer-exchange reactor is disabled. +seed_mode = false + +# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) +private_peer_ids = "" + +# Toggle to disable guard against peers connecting from the same ip. +allow_duplicate_ip = false + +# Peer connection configuration. +handshake_timeout = "20s" +dial_timeout = "3s" + +##### mempool configuration options ##### +[mempool] + +recheck = true +broadcast = true +wal_dir = "" + +# Maximum number of transactions in the mempool +size = 5000 + +# Limit the total size of all txs in the mempool. +# This only accounts for raw transactions (e.g. given 1MB transactions and +# max_txs_bytes=5MB, mempool will only accept 5 transactions). +max_txs_bytes = 1073741824 + +# Size of the cache (used to filter transactions we saw earlier) in transactions +cache_size = 10000 + +# Maximum size of a single transaction. +# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes} + {amino overhead}. +max_tx_bytes = 1048576 + +##### fast sync configuration options ##### +[fastsync] + +# Fast Sync version to use: +# 1) "v0" (default) - the legacy fast sync implementation +# 2) "v1" - refactor of v0 version for better testability +version = "v0" + +##### consensus configuration options ##### +[consensus] + +wal_file = "data/cs.wal/wal" + +timeout_propose = "3s" +timeout_propose_delta = "500ms" +timeout_prevote = "1s" +timeout_prevote_delta = "500ms" +timeout_precommit = "1s" +timeout_precommit_delta = "500ms" +timeout_commit = "5s" + +# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) +skip_timeout_commit = false + +# EmptyBlocks mode and possible interval between empty blocks +create_empty_blocks = true +create_empty_blocks_interval = "0s" + +# Reactor sleep duration parameters +peer_gossip_sleep_duration = "100ms" +peer_query_maj23_sleep_duration = "2s" + +##### transactions indexer configuration options ##### +[tx_index] + +# What indexer to use for transactions +# +# Options: +# 1) "null" +# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). +indexer = "kv" + +# Comma-separated list of tags to index (by default the only tag is "tx.hash") +# +# You can also index transactions by height by adding "tx.height" tag here. +# +# It's recommended to index only a subset of tags due to possible memory +# bloat. This is, of course, depends on the indexer's DB and the volume of +# transactions. +index_tags = "" + +# When set to true, tells indexer to index all tags (predefined tags: +# "tx.hash", "tx.height" and all tags from DeliverTx responses). +# +# Note this may be not desirable (see the comment above). IndexTags has a +# precedence over IndexAllTags (i.e. when given both, IndexTags will be +# indexed). +index_all_tags = true + +##### instrumentation configuration options ##### +[instrumentation] + +# When true, Prometheus metrics are served under /metrics on +# PrometheusListenAddr. +# Check out the documentation for the list of available metrics. +prometheus = false + +# Address to listen for Prometheus collector(s) connections +prometheus_listen_addr = ":26660" + +# Maximum number of simultaneous connections. +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +max_open_connections = 3 + +# Instrumentation namespace +namespace = "tendermint" diff --git a/scripts/cosm/.gaiad/config/genesis.json b/scripts/cosm/.gaiad/config/genesis.json new file mode 100644 index 00000000..e2a008c2 --- /dev/null +++ b/scripts/cosm/.gaiad/config/genesis.json @@ -0,0 +1,196 @@ +{ + "genesis_time": "2019-09-26T13:28:58.047804Z", + "chain_id": "testing", + "consensus_params": { + "block": { + "max_bytes": "22020096", + "max_gas": "-1", + "time_iota_ms": "1000" + }, + "evidence": { + "max_age": "100000" + }, + "validator": { + "pub_key_types": ["ed25519"] + } + }, + "app_hash": "", + "app_state": { + "bank": { + "send_enabled": true + }, + "genutil": { + "gentxs": [ + { + "type": "cosmos-sdk/StdTx", + "value": { + "msg": [ + { + "type": "cosmos-sdk/MsgCreateValidator", + "value": { + "description": { + "moniker": "testing", + "identity": "", + "website": "", + "details": "" + }, + "commission": { + "rate": "0.100000000000000000", + "max_rate": "0.200000000000000000", + "max_change_rate": "0.010000000000000000" + }, + "min_self_delegation": "1", + "delegator_address": "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", + "validator_address": "cosmosvaloper1pkptre7fdkl6gfrzlesjjvhxhlc3r4gm7znkuf", + "pubkey": "cosmosvalconspub1zcjduepqmktrr4rjkp8lje2lxcpdkf27tpyfv8w74czsasvthr3qc4encahsj85lva", + "value": { + "denom": "stake", + "amount": "100000000" + } + } + } + ], + "fee": { + "amount": [], + "gas": "200000" + }, + "signatures": [ + { + "pub_key": { + "type": "tendermint/PubKeySecp256k1", + "value": "A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ" + }, + "signature": "7yxA/j9y58XGRMv336J75p8CCfCDtslpr0hk9FA2GCIsvqgimwrUJ2sXMPbkx6EYj7gpvrrPZ9MY6pnIC2M9YQ==" + } + ], + "memo": "223aedddd9442bcf16641858ca85837f27997d0d@192.168.178.20:26656" + } + } + ] + }, + "auth": { + "params": { + "max_memo_characters": "256", + "tx_sig_limit": "7", + "tx_size_cost_per_byte": "10", + "sig_verify_cost_ed25519": "590", + "sig_verify_cost_secp256k1": "1000" + } + }, + "slashing": { + "params": { + "max_evidence_age": "120000000000", + "signed_blocks_window": "100", + "min_signed_per_window": "0.500000000000000000", + "downtime_jail_duration": "600000000000", + "slash_fraction_double_sign": "0.050000000000000000", + "slash_fraction_downtime": "0.010000000000000000" + }, + "signing_infos": {}, + "missed_blocks": {} + }, + "mint": { + "minter": { + "inflation": "0.130000000000000000", + "annual_provisions": "0.000000000000000000" + }, + "params": { + "mint_denom": "stake", + "inflation_rate_change": "0.130000000000000000", + "inflation_max": "0.200000000000000000", + "inflation_min": "0.070000000000000000", + "goal_bonded": "0.670000000000000000", + "blocks_per_year": "6311520" + } + }, + "staking": { + "params": { + "unbonding_time": "1814400000000000", + "max_validators": 100, + "max_entries": 7, + "bond_denom": "stake" + }, + "last_total_power": "0", + "last_validator_powers": null, + "validators": null, + "delegations": null, + "unbonding_delegations": null, + "redelegations": null, + "exported": false + }, + "distribution": { + "fee_pool": { + "community_pool": [] + }, + "community_tax": "0.020000000000000000", + "base_proposer_reward": "0.010000000000000000", + "bonus_proposer_reward": "0.040000000000000000", + "withdraw_addr_enabled": true, + "delegator_withdraw_infos": [], + "previous_proposer": "", + "outstanding_rewards": [], + "validator_accumulated_commissions": [], + "validator_historical_rewards": [], + "validator_current_rewards": [], + "delegator_starting_infos": [], + "validator_slash_events": [] + }, + "gov": { + "starting_proposal_id": "1", + "deposits": null, + "votes": null, + "proposals": null, + "deposit_params": { + "min_deposit": [ + { + "denom": "stake", + "amount": "10000000" + } + ], + "max_deposit_period": "172800000000000" + }, + "voting_params": { + "voting_period": "172800000000000" + }, + "tally_params": { + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto": "0.334000000000000000" + } + }, + "crisis": { + "constant_fee": { + "denom": "stake", + "amount": "1000" + } + }, + "accounts": [ + { + "address": "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", + "coins": [ + { + "denom": "stake", + "amount": "1000000000" + }, + { + "denom": "uatom", + "amount": "1000000000" + } + ], + "sequence_number": "0", + "account_number": "0", + "original_vesting": [], + "delegated_free": [], + "delegated_vesting": [], + "start_time": "0", + "end_time": "0", + "module_name": "", + "module_permissions": [""] + } + ], + "params": null, + "supply": { + "supply": [] + } + } +} diff --git a/scripts/cosm/.gaiad/config/gentx/gentx-223aedddd9442bcf16641858ca85837f27997d0d.json b/scripts/cosm/.gaiad/config/gentx/gentx-223aedddd9442bcf16641858ca85837f27997d0d.json new file mode 100644 index 00000000..81024488 --- /dev/null +++ b/scripts/cosm/.gaiad/config/gentx/gentx-223aedddd9442bcf16641858ca85837f27997d0d.json @@ -0,0 +1,39 @@ +{ + "type": "cosmos-sdk/StdTx", + "value": { + "msg": [ + { + "type": "cosmos-sdk/MsgCreateValidator", + "value": { + "description": { + "moniker": "testing", + "identity": "", + "website": "", + "details": "" + }, + "commission": { + "rate": "0.100000000000000000", + "max_rate": "0.200000000000000000", + "max_change_rate": "0.010000000000000000" + }, + "min_self_delegation": "1", + "delegator_address": "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", + "validator_address": "cosmosvaloper1pkptre7fdkl6gfrzlesjjvhxhlc3r4gm7znkuf", + "pubkey": "cosmosvalconspub1zcjduepqmktrr4rjkp8lje2lxcpdkf27tpyfv8w74czsasvthr3qc4encahsj85lva", + "value": { "denom": "stake", "amount": "100000000" } + } + } + ], + "fee": { "amount": [], "gas": "200000" }, + "signatures": [ + { + "pub_key": { + "type": "tendermint/PubKeySecp256k1", + "value": "A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ" + }, + "signature": "7yxA/j9y58XGRMv336J75p8CCfCDtslpr0hk9FA2GCIsvqgimwrUJ2sXMPbkx6EYj7gpvrrPZ9MY6pnIC2M9YQ==" + } + ], + "memo": "223aedddd9442bcf16641858ca85837f27997d0d@192.168.178.20:26656" + } +} diff --git a/scripts/cosm/.gaiad/config/node_key.json b/scripts/cosm/.gaiad/config/node_key.json new file mode 100644 index 00000000..0fd599b7 --- /dev/null +++ b/scripts/cosm/.gaiad/config/node_key.json @@ -0,0 +1,6 @@ +{ + "priv_key": { + "type": "tendermint/PrivKeyEd25519", + "value": "JBAVpjZD9g6ihHLpAaNFTHAx9muE38CGycyrJh+6TUvW28k/EVCKNEbYgqol7jvGRDv1kb2gw/HDH/P4nHG+wQ==" + } +} diff --git a/scripts/cosm/.gaiad/config/priv_validator_key.json b/scripts/cosm/.gaiad/config/priv_validator_key.json new file mode 100644 index 00000000..41def821 --- /dev/null +++ b/scripts/cosm/.gaiad/config/priv_validator_key.json @@ -0,0 +1,11 @@ +{ + "address": "3A7EBE1A9E333146AE5D9FCB765B88BDD4D2859A", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "3ZYx1HKwT/llXzYC2yVeWEiWHd6uBQ7Bi7jiDFczx28=" + }, + "priv_key": { + "type": "tendermint/PrivKeyEd25519", + "value": "MijGfx+4vztrhMdzGY20nPqriHUgqbwYLdM5Rtft11XdljHUcrBP+WVfNgLbJV5YSJYd3q4FDsGLuOIMVzPHbw==" + } +} diff --git a/scripts/cosm/.gitignore b/scripts/cosm/.gitignore new file mode 100644 index 00000000..3f8523cf --- /dev/null +++ b/scripts/cosm/.gitignore @@ -0,0 +1,2 @@ +.gaiacli/keys/ +.gaiad/data/ diff --git a/scripts/cosm/README.md b/scripts/cosm/README.md new file mode 100644 index 00000000..a7248f5d --- /dev/null +++ b/scripts/cosm/README.md @@ -0,0 +1,80 @@ +# Local Cosmos test network + +## Starting the blockchain + +Run the following: + +``` +./start.sh +``` + +## CLI + +Docker-friendly access to `gaiacli` is provided. Just use the `./cli.sh` script. +For example: + +``` +./cli.sh status +``` + +This should give you output similar to the following if your blockchain is +running: + +```json +{ + "node_info": { + "protocol_version": { "p2p": "7", "block": "10", "app": "0" }, + "id": "223aedddd9442bcf16641858ca85837f27997d0d", + "listen_addr": "tcp://0.0.0.0:26656", + "network": "testing", + "version": "0.32.2", + "channels": "4020212223303800", + "moniker": "testing", + "other": { "tx_index": "on", "rpc_address": "tcp://127.0.0.1:26657" } + }, + "sync_info": { + "latest_block_hash": "3E3BEBCFA4E47BC67C7DE44DD4E83D8D42235DE75DA942A6BECD1F0F5A6246E4", + "latest_app_hash": "73A3641BDEFBB728B1B48FB87B510F3E76E3B4519BC4954C6E1060738FCE8B14", + "latest_block_height": "1217", + "latest_block_time": "2019-09-26T15:44:13.0111312Z", + "catching_up": false + }, + "validator_info": { + "address": "3A7EBE1A9E333146AE5D9FCB765B88BDD4D2859A", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "3ZYx1HKwT/llXzYC2yVeWEiWHd6uBQ7Bi7jiDFczx28=" + }, + "voting_power": "100" + } +} +``` + +## Adding the validator key to your keybase + +The Cosmos test network is initialised with a validator (see +`.gaiad/config/genesis.json`). This validator has the following mnemonic: + +``` +economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone +``` + +To add the validator key to your local keybase run the following, choose an +encryption passphrase (e.g. `testing123`) and enter the above mnemonic when +prompted: + +``` +./cli.sh keys add validator --recover +``` + +You should get output matching the following: + +``` +- name: validator + type: local + address: cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6 + pubkey: cosmospub1addwnpepqd8sgxq7aw348ydctp3n5ajufgxp395hksxjzc6565yfp56scupfqhlgyg5 + mnemonic: "" + threshold: 0 + pubkeys: [] +``` diff --git a/scripts/cosm/cli.sh b/scripts/cosm/cli.sh new file mode 100755 index 00000000..5487cfa2 --- /dev/null +++ b/scripts/cosm/cli.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck > /dev/null && shellcheck "$0" + +# Choose from https://hub.docker.com/r/tendermint/gaia/tags +VERSION="v2.0.0" +CURRENT_DIR="$(realpath "$(dirname "$0")")" +GAIAD_CONTAINER_NAME="gaiad" +HOME_DIR="/home" + +docker run \ + --rm \ + --user="$UID" \ + -it \ + -v "$CURRENT_DIR/.gaiad:$HOME_DIR/.gaiad" \ + -v "$CURRENT_DIR/.gaiacli:$HOME_DIR/.gaiacli" \ + -w "$HOME_DIR" \ + --env "HOME=$HOME_DIR" \ + --net "container:$GAIAD_CONTAINER_NAME" \ + "tendermint/gaia:${VERSION}" \ + gaiacli "$@" diff --git a/scripts/cosm/priv_validator_state.template.json b/scripts/cosm/priv_validator_state.template.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/scripts/cosm/priv_validator_state.template.json @@ -0,0 +1 @@ +{} diff --git a/scripts/cosm/start.sh b/scripts/cosm/start.sh new file mode 100755 index 00000000..240e15a4 --- /dev/null +++ b/scripts/cosm/start.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck > /dev/null && shellcheck "$0" + +# Choose from https://hub.docker.com/r/tendermint/gaia/tags +VERSION="v2.0.4" + +TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/gaia.XXXXXXXXX") +chmod 777 "$TMP_DIR" +echo "Using temporary dir $TMP_DIR" +GAIAD_LOGFILE="$TMP_DIR/gaiad.log" +REST_SERVER_LOGFILE="$TMP_DIR/rest-server.log" +CURRENT_DIR="$(realpath "$(dirname "$0")")" +HOME_DIR="/home" +CONTAINER_NAME="gaiad" + +rm -rf "$CURRENT_DIR/.gaiad/data" +mkdir -p "$CURRENT_DIR/.gaiad/data" +cp "$CURRENT_DIR/priv_validator_state.template.json" "$CURRENT_DIR/.gaiad/data/priv_validator_state.json" + +docker run \ + --rm \ + --user="$UID" \ + -t \ + --name "$CONTAINER_NAME" \ + -v "$CURRENT_DIR/.gaiad:$HOME_DIR/.gaiad" \ + -v "$CURRENT_DIR/.gaiacli:$HOME_DIR/.gaiacli" \ + -w "$HOME_DIR" \ + --env "HOME=$HOME_DIR" \ + -p 46656:46656 \ + -p 46657:46657 \ + -p 1317:1317 \ + "tendermint/gaia:${VERSION}" \ + gaiad start \ + --rpc.laddr tcp://0.0.0.0:46657 \ + > "$GAIAD_LOGFILE" & + +echo "gaiad running and logging into $GAIAD_LOGFILE" + +sleep 10 + +docker exec "$CONTAINER_NAME" \ + gaiacli rest-server \ + --node tcp://localhost:46657 \ + --trust-node \ + --laddr tcp://0.0.0.0:1317 \ + > "$REST_SERVER_LOGFILE" & + +echo "rest server running on http://localhost:1317 and logging into $REST_SERVER_LOGFILE" diff --git a/scripts/cosm/stop.sh b/scripts/cosm/stop.sh new file mode 100755 index 00000000..fba38e82 --- /dev/null +++ b/scripts/cosm/stop.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck > /dev/null && shellcheck "$0" + +GAIAD_CONTAINER_NAME="gaiad" + +echo "Killing Cosmos container..." +docker container kill "$GAIAD_CONTAINER_NAME" diff --git a/scripts/iov_faucet_start.sh b/scripts/iov_faucet_start.sh new file mode 100755 index 00000000..2c8e7972 --- /dev/null +++ b/scripts/iov_faucet_start.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck > /dev/null && shellcheck "$0" + +# Choose from https://hub.docker.com/r/iov1/iov-faucet/tags/ +FAUCET_VERSION="v0.8.1" + +TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/faucet_start.XXXXXXXXX") +LOGFILE="$TMP_DIR/faucet.log" + +DOCKER_HOST_IP=$(docker run --rm alpine ip route | awk 'NR==1 {print $3}') + +BLOCKCHAIN_URL="ws://$DOCKER_HOST_IP:23456" +echo "Connecting to $BLOCKCHAIN_URL" + +docker run --rm \ + --read-only \ + --env "FAUCET_CONCURRENCY=3" \ + --env "FAUCET_MNEMONIC=degree tackle suggest window test behind mesh extra cover prepare oak script" \ + -p 8000:8000 \ + "iov1/iov-faucet:${FAUCET_VERSION}" \ + start bns "$BLOCKCHAIN_URL" \ + > "$LOGFILE" & + +echo "Faucet running and logging into $LOGFILE" diff --git a/scripts/iov_faucet_stop.sh b/scripts/iov_faucet_stop.sh new file mode 100755 index 00000000..af68ceca --- /dev/null +++ b/scripts/iov_faucet_stop.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck > /dev/null && shellcheck "$0" + +LABEL_PART="iov1/iov-faucet" + +CONTAINER_ID=$(docker container ls | grep -F "$LABEL_PART:" | awk '{print $1}') +echo "Killing $LABEL_PART container '$CONTAINER_ID' ..." +docker container kill "$CONTAINER_ID"