From ec16913761989fa4f561781f1bfc7c7e2cd8724f Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Wed, 11 Oct 2023 17:31:49 +0200 Subject: [PATCH 1/2] feat: use docker-compose for local transaction replication Signed-off-by: Antonio Navarro Perez --- Dockerfile | 9 +++++-- docker-compose.yml | 47 +++++++++++++++++++++++++++++++++++ gno.land/cmd/gnoland/start.go | 8 ------ 3 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 9e7fc48dcb0..c85411cc045 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,12 +21,17 @@ ENV PATH="${PATH}:/opt/gno/bin" \ GNOROOT="/opt/gno/src" WORKDIR /opt/gno/src FROM runtime-base AS runtime-tls -RUN apt-get update && apt-get install -y expect ca-certificates && update-ca-certificates +RUN apt-get update && apt-get install -y expect ca-certificates curl && update-ca-certificates # slim images -FROM runtime-base AS gnoland-slim +FROM runtime-tls AS gnoland-slim +ADD ./gno.land/genesis /opt/gno/src/gno.land/genesis +ADD ./examples /opt/gno/src/examples +ADD ./gnovm/stdlibs /opt/gno/src/gnovm/stdlibs WORKDIR /opt/gno/src/gno.land/ COPY --from=build /opt/build/build/gnoland /opt/gno/bin/ +RUN mkdir config +#TODO: RUN echo '[rpc]\nladdr = "tcp://0.0.0.0:26657"' > config/config.toml ENTRYPOINT ["gnoland"] EXPOSE 26657 36657 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000000..3ec18159a79 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,47 @@ +version: '3.2' +services: + node: + ports: + - target: 26657 + published: "26657" + mode: host + command: start -genesis-remote 0.0.0.0:26657 -root-dir . + build: + context: . + target: gnoland-slim + deploy: + restart_policy: + condition: on-failure + delay: 5s + window: 10s + healthcheck: + test: curl -X POST -f http://0.0.0.0:26657/status || exit 1 + interval: 5s + timeout: 5s + start_period: 30s + start_interval: 1s + archiver-backup: + image: ghcr.io/gnolang/tx-archive:latest + command: backup -remote https://test3.gno.land:36657 -watch -output-path /data/backup.jsonl -overwrite + deploy: + restart_policy: + condition: on-failure + delay: 5s + window: 10s + volumes: + - ./archiver-data:/data + archiver-restorer: + depends_on: + node: + condition: service_healthy + archiver-backup: + condition: service_started + image: ghcr.io/gnolang/tx-archive:latest + command: restore -remote http://node:26657 -watch -input-path /data/backup.jsonl + deploy: + restart_policy: + condition: on-failure + delay: 5s + window: 10s + volumes: + - ./archiver-data:/data diff --git a/gno.land/cmd/gnoland/start.go b/gno.land/cmd/gnoland/start.go index b2134d86ea9..ad190e727d2 100644 --- a/gno.land/cmd/gnoland/start.go +++ b/gno.land/cmd/gnoland/start.go @@ -34,7 +34,6 @@ type startCfg struct { genesisRemote string rootDir string genesisMaxVMCycles int64 - config string } func newStartCmd(io *commands.IO) *commands.Command { @@ -109,13 +108,6 @@ func (c *startCfg) RegisterFlags(fs *flag.FlagSet) { 10_000_000, "set maximum allowed vm cycles per operation. Zero means no limit.", ) - - fs.StringVar( - &c.config, - "config", - "", - "config file (optional)", - ) } func execStart(c *startCfg, args []string, io *commands.IO) error { From c37c7a2b9d48ed8774385c85d49c1256c96e65a0 Mon Sep 17 00:00:00 2001 From: Antonio Navarro Date: Wed, 18 Oct 2023 12:27:06 -0400 Subject: [PATCH 2/2] Move docker-compose file to its folder Make everything work porperly adding a toml config gile Signed-off-by: Antonio Navarro --- .dockerignore | 1 - .gitignore | 1 + Dockerfile | 3 +- docker-compose.yml | 47 ----- misc/docker-compose/default-config.toml | 236 ++++++++++++++++++++++++ misc/docker-compose/docker-compose.yml | 66 ++++--- 6 files changed, 282 insertions(+), 72 deletions(-) delete mode 100644 docker-compose.yml create mode 100644 misc/docker-compose/default-config.toml diff --git a/.dockerignore b/.dockerignore index caecb619cd6..ccbbac63354 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,6 @@ .dockerignore build/ Dockerfile -misc/ docker-compose.yml tests/docker-integration/ diff --git a/.gitignore b/.gitignore index d7e6d7eb9a4..a1a2c23eab6 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ pbbindings.go *# cover.out coverage.out +misc/docker-compose/archiver-data \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c85411cc045..532b3d7c40f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,10 +28,9 @@ FROM runtime-tls AS gnoland-slim ADD ./gno.land/genesis /opt/gno/src/gno.land/genesis ADD ./examples /opt/gno/src/examples ADD ./gnovm/stdlibs /opt/gno/src/gnovm/stdlibs +ADD ./misc/docker-compose/default-config.toml /opt/gno/src/gno.land/config/config.toml WORKDIR /opt/gno/src/gno.land/ COPY --from=build /opt/build/build/gnoland /opt/gno/bin/ -RUN mkdir config -#TODO: RUN echo '[rpc]\nladdr = "tcp://0.0.0.0:26657"' > config/config.toml ENTRYPOINT ["gnoland"] EXPOSE 26657 36657 diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 3ec18159a79..00000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,47 +0,0 @@ -version: '3.2' -services: - node: - ports: - - target: 26657 - published: "26657" - mode: host - command: start -genesis-remote 0.0.0.0:26657 -root-dir . - build: - context: . - target: gnoland-slim - deploy: - restart_policy: - condition: on-failure - delay: 5s - window: 10s - healthcheck: - test: curl -X POST -f http://0.0.0.0:26657/status || exit 1 - interval: 5s - timeout: 5s - start_period: 30s - start_interval: 1s - archiver-backup: - image: ghcr.io/gnolang/tx-archive:latest - command: backup -remote https://test3.gno.land:36657 -watch -output-path /data/backup.jsonl -overwrite - deploy: - restart_policy: - condition: on-failure - delay: 5s - window: 10s - volumes: - - ./archiver-data:/data - archiver-restorer: - depends_on: - node: - condition: service_healthy - archiver-backup: - condition: service_started - image: ghcr.io/gnolang/tx-archive:latest - command: restore -remote http://node:26657 -watch -input-path /data/backup.jsonl - deploy: - restart_policy: - condition: on-failure - delay: 5s - window: 10s - volumes: - - ./archiver-data:/data diff --git a/misc/docker-compose/default-config.toml b/misc/docker-compose/default-config.toml new file mode 100644 index 00000000000..8cd1fe805b6 --- /dev/null +++ b/misc/docker-compose/default-config.toml @@ -0,0 +1,236 @@ +# 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://0.0.0.0:26658" + +# A custom human readable name for this node +moniker = "voyager.local" + +# 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/gnolang/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 - go.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 = "" + +# 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://0.0.0.0: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", "OPTIONS", ] + +# 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 + +# 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/classic/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 + +# 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_pending_txs_bytes = 1073741824 + +# Size of the cache (used to filter transactions we saw earlier) in transactions +cache_size = 10000 + +##### 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" \ No newline at end of file diff --git a/misc/docker-compose/docker-compose.yml b/misc/docker-compose/docker-compose.yml index 26ef50913ff..c11e0889ea6 100644 --- a/misc/docker-compose/docker-compose.yml +++ b/misc/docker-compose/docker-compose.yml @@ -1,25 +1,47 @@ -version: "3.7" +version: '3.2' services: - gnonode: - container_name: gnoland-node + node: + ports: + - target: 26657 + published: "26657" + mode: host + command: start -genesis-remote 0.0.0.0:26657 -root-dir . build: - context: . - dockerfile: ../..Dockerfile - environment: - - LOG_LEVEL=4 - command: [ "gnoland", "start" ] + context: ../../. + target: gnoland-slim + deploy: + restart_policy: + condition: on-failure + delay: 5s + window: 10s + healthcheck: + test: curl -X POST -f http://0.0.0.0:26657/status || exit 1 + interval: 5s + timeout: 5s + start_period: 30s + start_interval: 1s + archiver-backup: + image: ghcr.io/gnolang/tx-archive:latest + command: backup -remote https://test3.gno.land:36657 -watch -output-path /data/backup.jsonl -overwrite + deploy: + restart_policy: + condition: on-failure + delay: 5s + window: 10s volumes: - - "gnonode:/opt/gno/src/testdir" - networks: - - gnonode - restart: on-failure - logging: - driver: "json-file" - options: - max-file: "10" - max-size: "100m" - -networks: - gnonode: {} -volumes: - gnonode: {} + - ./archiver-data:/data + archiver-restorer: + depends_on: + node: + condition: service_healthy + archiver-backup: + condition: service_started + image: ghcr.io/gnolang/tx-archive:latest + command: restore -remote http://node:26657 -watch -input-path /data/backup.jsonl + deploy: + restart_policy: + condition: on-failure + delay: 5s + window: 10s + volumes: + - ./archiver-data:/data