From ac5440585f129f3064e9013035e42cec2f10109d Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Mon, 13 Mar 2023 19:34:04 +0700 Subject: [PATCH 01/13] add last_update for channels --- flusher/flusher/db.py | 1 + flusher/flusher/handler.py | 13 +++++++++++++ hooks/emitter/channel.go | 2 ++ 3 files changed, 16 insertions(+) diff --git a/flusher/flusher/db.py b/flusher/flusher/db.py index 868215898..6cbf45ef7 100644 --- a/flusher/flusher/db.py +++ b/flusher/flusher/db.py @@ -460,4 +460,5 @@ def Column(*args, **kwargs): Column("counterparty_channel", sa.String), Column("state", sa.Integer), Column("order", sa.String), + Column("last_update", CustomDateTime, index=True), ) diff --git a/flusher/flusher/handler.py b/flusher/flusher/handler.py index c5bff6aaa..a81f83b1f 100644 --- a/flusher/flusher/handler.py +++ b/flusher/flusher/handler.py @@ -399,13 +399,26 @@ def handle_new_incoming_packet(self, msg): ) def handle_new_outgoing_packet(self, msg): + self.conn.execute( + channels.update(channels.c.port == msg['src_port'] & channels.c.port == msg['src_channel']).values( + last_update=msg['block_time'] + ) + ) + msg["tx_id"] = self.get_transaction_id(msg["hash"]) del msg["hash"] + self.conn.execute( insert(outgoing_packets).values(**msg).on_conflict_do_nothing(constraint="outgoing_packets_pkey") ) def handle_update_outgoing_packet(self, msg): + self.conn.execute( + channels.update(channels.c.port == msg['dst_port'] & channels.c.port == msg['dst_channel']).values( + last_update=msg['block_time'] + ) + ) + condition = True for col in outgoing_packets.primary_key.columns.values(): condition = (col == msg[col.name]) & condition diff --git a/hooks/emitter/channel.go b/hooks/emitter/channel.go index 0b41b6b94..0bef25ac3 100644 --- a/hooks/emitter/channel.go +++ b/hooks/emitter/channel.go @@ -25,6 +25,7 @@ func (h *Hook) emitSetChannel(ctx sdk.Context, portId string, channelId string) "counterparty_channel": channel.Counterparty.ChannelId, "state": channel.State, "order": channel.Ordering, + "last_update": ctx.BlockTime().UnixNano(), }) } @@ -109,6 +110,7 @@ func newPacket( ) common.JsDict { return common.JsDict{ "block_height": ctx.BlockHeight(), + "block_time": ctx.BlockTime().UnixNano(), "src_channel": srcChannel, "src_port": srcPort, "sequence": sequence, From 418156158ee40e4d31af5ce0f092a52195e985cd Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Mon, 13 Mar 2023 20:54:51 +0700 Subject: [PATCH 02/13] fixed error --- flusher/flusher/handler.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/flusher/flusher/handler.py b/flusher/flusher/handler.py index a81f83b1f..b60b2ad84 100644 --- a/flusher/flusher/handler.py +++ b/flusher/flusher/handler.py @@ -392,6 +392,9 @@ def handle_set_request_count_per_day(self, msg): ) def handle_new_incoming_packet(self, msg): + self.update_last_update_channel(msg) + del msg["block_time"] + msg["tx_id"] = self.get_transaction_id(msg["hash"]) del msg["hash"] self.conn.execute( @@ -399,11 +402,8 @@ def handle_new_incoming_packet(self, msg): ) def handle_new_outgoing_packet(self, msg): - self.conn.execute( - channels.update(channels.c.port == msg['src_port'] & channels.c.port == msg['src_channel']).values( - last_update=msg['block_time'] - ) - ) + self.update_last_update_channel(msg) + del msg["block_time"] msg["tx_id"] = self.get_transaction_id(msg["hash"]) del msg["hash"] @@ -413,11 +413,8 @@ def handle_new_outgoing_packet(self, msg): ) def handle_update_outgoing_packet(self, msg): - self.conn.execute( - channels.update(channels.c.port == msg['dst_port'] & channels.c.port == msg['dst_channel']).values( - last_update=msg['block_time'] - ) - ) + self.update_last_update_channel(msg) + del msg["block_time"] condition = True for col in outgoing_packets.primary_key.columns.values(): @@ -452,3 +449,10 @@ def handle_set_connection(self, msg): def handle_set_channel(self, msg): self.conn.execute(insert(channels).values(**msg).on_conflict_do_update(constraint="channels_pkey", set_=msg)) + + def update_last_update_channel(self, msg): + self.conn.execute( + channels.update().where(channels.c.port == msg['dst_port'] & channels.c.port == msg['dst_channel']).values( + last_update=msg['block_time'] + ) + ) From 1c690fa4be8ad57e2783997f978145be48d65643 Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Mon, 13 Mar 2023 21:19:26 +0700 Subject: [PATCH 03/13] add parenthesis --- flusher/flusher/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flusher/flusher/handler.py b/flusher/flusher/handler.py index b60b2ad84..a0f53bf20 100644 --- a/flusher/flusher/handler.py +++ b/flusher/flusher/handler.py @@ -452,7 +452,7 @@ def handle_set_channel(self, msg): def update_last_update_channel(self, msg): self.conn.execute( - channels.update().where(channels.c.port == msg['dst_port'] & channels.c.port == msg['dst_channel']).values( + channels.update().where((channels.c.port == msg['dst_port']) & (channels.c.port == msg['dst_channel'])).values( last_update=msg['block_time'] ) ) From a8d9362e5258fc2797efb493c88152e14bd0c6af Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Mon, 13 Mar 2023 21:40:53 +0700 Subject: [PATCH 04/13] updat --- flusher/flusher/handler.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flusher/flusher/handler.py b/flusher/flusher/handler.py index a0f53bf20..d41ca19ab 100644 --- a/flusher/flusher/handler.py +++ b/flusher/flusher/handler.py @@ -392,7 +392,7 @@ def handle_set_request_count_per_day(self, msg): ) def handle_new_incoming_packet(self, msg): - self.update_last_update_channel(msg) + self.update_last_update_channel(msg['dst_port'], msg['dst_channel'], msg['block_time']) del msg["block_time"] msg["tx_id"] = self.get_transaction_id(msg["hash"]) @@ -402,7 +402,7 @@ def handle_new_incoming_packet(self, msg): ) def handle_new_outgoing_packet(self, msg): - self.update_last_update_channel(msg) + self.update_last_update_channel(msg['src_port'], msg['src_channel'], msg['block_time']) del msg["block_time"] msg["tx_id"] = self.get_transaction_id(msg["hash"]) @@ -413,7 +413,7 @@ def handle_new_outgoing_packet(self, msg): ) def handle_update_outgoing_packet(self, msg): - self.update_last_update_channel(msg) + self.update_last_update_channel(msg['src_port'], msg['src_channel'], msg['block_time']) del msg["block_time"] condition = True @@ -450,9 +450,9 @@ def handle_set_connection(self, msg): def handle_set_channel(self, msg): self.conn.execute(insert(channels).values(**msg).on_conflict_do_update(constraint="channels_pkey", set_=msg)) - def update_last_update_channel(self, msg): + def update_last_update_channel(self, port, channel, timestamp): self.conn.execute( - channels.update().where((channels.c.port == msg['dst_port']) & (channels.c.port == msg['dst_channel'])).values( - last_update=msg['block_time'] + channels.update().where((channels.c.port == port) & (channels.c.channel == channel)).values( + last_update=timestamp ) ) From d6d36e41e5d984d76c830049d6f1785e8af6000c Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Fri, 17 Mar 2023 14:11:10 +0700 Subject: [PATCH 05/13] use container name instead of ip --- docker-compose.yaml | 71 +++++++++++------------------------ docker-config/run.sh | 9 ++--- docker-config/start_docker.sh | 15 ++++---- flusher/Dockerfile | 2 +- proxy-ssl/nginx.conf | 10 ++--- proxy/default.vcl | 8 ++-- 6 files changed, 43 insertions(+), 72 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 5e40e975b..9f600e764 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,35 +7,31 @@ services: dockerfile: Dockerfile image: band-validator:latest networks: - bandchain: - ipv4_address: 172.18.0.11 + - bandchain command: sh -c "chmod +x ./run.sh && ./run.sh validator1" multi-validator2-node: image: band-validator:latest networks: - bandchain: - ipv4_address: 172.18.0.12 + - bandchain command: sh -c "chmod +x ./run.sh && ./run.sh validator2" multi-validator3-node: image: band-validator:latest networks: - bandchain: - ipv4_address: 172.18.0.13 + - bandchain command: sh -c "chmod +x ./run.sh && ./run.sh validator3" multi-validator4-node: image: band-validator:latest networks: - bandchain: - ipv4_address: 172.18.0.14 + - bandchain command: sh -c "chmod +x ./run.sh && ./run.sh validator4" emitter-node: image: band-validator:latest networks: - bandchain: + - bandchain command: sh -c "chmod +x ./run.sh && ./run.sh emitter" query-node: @@ -45,26 +41,15 @@ services: - 1317:1317 - 9090:9090 networks: - bandchain: - ipv4_address: 172.18.0.15 + - bandchain command: sh -c "chmod +x ./run.sh && ./run.sh query-node" - # rest-server: - # image: band-validator:latest - # networks: - # bandchain: - # ipv4_address: 172.18.0.20 - # restart: always - # ports: - # - 1317:1317 - # command: bandcli rest-server --laddr tcp://0.0.0.0:1317 --node tcp://172.18.0.15:26657 --chain-id bandchain --trust-node proxy-server: build: context: ./proxy image: proxy-server:latest networks: - bandchain: - ipv4_address: 172.18.0.99 + - bandchain depends_on: - query-node ports: @@ -75,8 +60,7 @@ services: context: ./proxy-ssl image: proxy-ssl-server:latest networks: - bandchain: - ipv4_address: 172.18.0.98 + - bandchain depends_on: - query-node ports: @@ -89,9 +73,10 @@ services: postgres: image: postgres:12 restart: always + ports: + - "5432:5432" networks: - bandchain: - ipv4_address: 172.18.0.88 + - bandchain environment: POSTGRES_PASSWORD: postgrespassword @@ -100,44 +85,35 @@ services: context: ./hasura image: hasura:latest ports: - - "5433:5433" + - "5433:8080" depends_on: - "postgres" restart: always networks: - bandchain: - ipv4_address: 172.18.0.89 + - bandchain environment: - HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@172.18.0.88:5432/postgres - HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@172.18.0.88:5432/postgres + HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres + HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres HASURA_GRAPHQL_ENABLE_CONSOLE: "true" HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log HASURA_GRAPHQL_SERVER_HOST: 0.0.0.0 - HASURA_GRAPHQL_SERVER_PORT: 5433 HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES: "true" volumes: - ./hasura/hasura-metadata:/hasura-metadata - # TODO: Expose port to consume kafka from other zookeeper: image: wurstmeister/zookeeper - # ports: - # - "2181:2181" networks: - bandchain: - ipv4_address: 172.18.0.30 + - bandchain kafka: image: wurstmeister/kafka - # ports: - # - "9092:9092" networks: - bandchain: - ipv4_address: 172.18.0.31 + - bandchain environment: - KAFKA_ADVERTISED_HOST_NAME: 172.18.0.31 + KAFKA_ADVERTISED_HOST_NAME: kafka KAFKA_ADVERTISED_PORT: 9092 KAFKA_CREATE_TOPICS: test:1:1 - KAFKA_ZOOKEEPER_CONNECT: 172.18.0.30:2181 + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 volumes: - /var/run/docker.sock:/var/run/docker.sock @@ -147,17 +123,14 @@ services: image: bandchain_flusher:latest networks: bandchain: - command: sh -c "sleep 30 && python main.py init bandchain test replay --db postgres:postgrespassword@172.18.0.88:5432/postgres" + command: sh -c "sleep 30 && python main.py init bandchain test replay --db postgres:postgrespassword@postgres:5432/postgres" flusher-daemon: image: bandchain_flusher:latest networks: - bandchain: + - bandchain restart: always networks: bandchain: - ipam: - driver: default - config: - - subnet: "172.18.0.0/16" + driver: default diff --git a/docker-config/run.sh b/docker-config/run.sh index 3b61a9d80..fdee42249 100755 --- a/docker-config/run.sh +++ b/docker-config/run.sh @@ -13,14 +13,13 @@ fi if [ "$1" == "emitter" ];then sleep 60 - bandd start --with-emitter test@172.18.0.31:9092 \ - --p2p.persistent_peers 11392b605378063b1c505c0ab123f04bd710d7d7@172.18.0.11:26656,0851086afcd835d5a6fb0ffbf96fcdf74fec742e@172.18.0.12:26656,63808bd64f2ec19acb2a494c8ce8467c595f6fba@172.18.0.14:26656,7b58b086dd915a79836eb8bfa956aeb9488d13b0@172.18.0.13:26656 + bandd start --with-emitter test@kafka:9092 \ + --p2p.persistent_peers 11392b605378063b1c505c0ab123f04bd710d7d7@multi-validator1-node:26656,0851086afcd835d5a6fb0ffbf96fcdf74fec742e@multi-validator2-node:26656,63808bd64f2ec19acb2a494c8ce8467c595f6fba@multi-validator3-node:26656,7b58b086dd915a79836eb8bfa956aeb9488d13b0@multi-validator4-node:26656 elif [ "$1" == "query-node" ];then bandd start --rpc.laddr tcp://0.0.0.0:26657 \ - --p2p.persistent_peers 11392b605378063b1c505c0ab123f04bd710d7d7@172.18.0.11:26656,0851086afcd835d5a6fb0ffbf96fcdf74fec742e@172.18.0.12:26656,63808bd64f2ec19acb2a494c8ce8467c595f6fba@172.18.0.14:26656,7b58b086dd915a79836eb8bfa956aeb9488d13b0@172.18.0.13:26656 --pruning nothing \ - --with-request-search=sqlite3:rqsearch.db \ + --p2p.persistent_peers 11392b605378063b1c505c0ab123f04bd710d7d7@multi-validator1-node:26656,0851086afcd835d5a6fb0ffbf96fcdf74fec742e@multi-validator2-node:26656,63808bd64f2ec19acb2a494c8ce8467c595f6fba@multi-validator3-node:26656,7b58b086dd915a79836eb8bfa956aeb9488d13b0@multi-validator4-node:26656 --with-request-search=sqlite3:rqsearch.db \ --with-pricer=1 else bandd start --rpc.laddr tcp://0.0.0.0:26657 \ - --p2p.persistent_peers 11392b605378063b1c505c0ab123f04bd710d7d7@172.18.0.11:26656,0851086afcd835d5a6fb0ffbf96fcdf74fec742e@172.18.0.12:26656,63808bd64f2ec19acb2a494c8ce8467c595f6fba@172.18.0.14:26656,7b58b086dd915a79836eb8bfa956aeb9488d13b0@172.18.0.13:26656 + --p2p.persistent_peers 11392b605378063b1c505c0ab123f04bd710d7d7@multi-validator1-node:26656,0851086afcd835d5a6fb0ffbf96fcdf74fec742e@multi-validator2-node:26656,63808bd64f2ec19acb2a494c8ce8467c595f6fba@multi-validator3-node:26656,7b58b086dd915a79836eb8bfa956aeb9488d13b0@multi-validator4-node:26656 fi diff --git a/docker-config/start_docker.sh b/docker-config/start_docker.sh index 4761b391d..7104ad257 100755 --- a/docker-config/start_docker.sh +++ b/docker-config/start_docker.sh @@ -57,7 +57,7 @@ bandd gentx validator1 100000000uband \ --pubkey '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A/V/OZek6B2PMh6XEJJ+IsLm0w+22PdJqeSgevs7O3kJ"}' \ --details "Alice's Adventures in Wonderland (commonly shortened to Alice in Wonderland) is an 1865 novel written by English author Charles Lutwidge Dodgson under the pseudonym Lewis Carroll." \ --website "https://www.alice.org/" \ - --ip 172.18.0.11 \ + --ip multi-validator1-node \ --keyring-backend test # modify moniker @@ -69,7 +69,7 @@ bandd gentx validator2 100000000uband \ --pubkey '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AnJK4pz+t0lwUdCe39joIjUsTINht1dkdkW3jIzHTOiF"}' \ --details "Fish is best known for his appearances with Ring of Honor (ROH) from 2013 to 2017, where he wrestled as one-half of the tag team reDRagon and held the ROH World Tag Team Championship three times and the ROH World Television Championship once." \ --website "https://www.wwe.com/superstars/bobby-fish" \ - --ip 172.18.0.12 \ + --ip multi-validator2-node \ --keyring-backend test # modify moniker @@ -81,7 +81,7 @@ bandd gentx validator3 100000000uband \ --pubkey '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A6VP+qhMjy95h4Lei5YqhHhOKISHp0eBOghXJDpg4roz"}' \ --details "Carol Susan Jane Danvers is a fictional superhero appearing in American comic books published by Marvel Comics. Created by writer Roy Thomas and artist Gene Colan." \ --website "https://www.marvel.com/characters/captain-marvel-carol-danvers" \ - --ip 172.18.0.13 \ + --ip multi-validator3-node \ --keyring-backend test # modify moniker @@ -93,7 +93,7 @@ bandd gentx validator4 100000000uband \ --pubkey '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A9A3CPFh0Vg/SeQmCkKysI07oYbXgDojzDrNEvB02ddv"}' \ --details "Evil is an American supernatural drama television series created by Robert King and Michelle King that premiered on September 26, 2019, on CBS. The series is produced by CBS Television Studios and King Size Productions." \ --website "https://www.imdb.com/title/tt9055008/" \ - --ip 172.18.0.14 \ + --ip multi-validator4-node \ --keyring-backend test # remove temp test @@ -114,8 +114,7 @@ for v in {1..4} do rm -rf ~/.yoda yoda config chain-id bandchain - yoda config node tcp://172.18.0.1$v:26657 - yoda config chain-rest-server http://172.18.0.20:1317 + yoda config node tcp://localhost:26657 yoda config validator $(bandd keys show validator$v -a --bech val --keyring-backend test) yoda config executor "rest:https://asia-southeast2-band-playground.cloudfunctions.net/test-runtime-executor?timeout=10s" @@ -151,7 +150,7 @@ done # Create faucet container rm -rf ~/.faucet faucet config chain-id bandchain -faucet config node tcp://172.18.0.15:26657 +faucet config node tcp://localhost:26657 faucet config port 5005 for i in $(eval echo {1..5}) do @@ -165,6 +164,6 @@ do sleep 2 done -docker create --network chain_bandchain --name bandchain_faucet -p 5005:5005 --ip 172.18.0.17 band-validator:latest faucet r +docker create --network chain_bandchain --name bandchain_faucet -p 5005:5005 band-validator:latest faucet r docker cp ~/.faucet bandchain_faucet:/root/.faucet docker start bandchain_faucet diff --git a/flusher/Dockerfile b/flusher/Dockerfile index 64481cb86..da73ae705 100644 --- a/flusher/Dockerfile +++ b/flusher/Dockerfile @@ -5,4 +5,4 @@ RUN apt-get update && apt-get install -y libpq-dev gcc RUN pip install -r requirements.txt # TODO: Using environment variable for db and kafka bootstrap services -CMD python main.py sync --db postgres:postgrespassword@172.18.0.88:5432/postgres -s 172.18.0.31:9092 +CMD python main.py sync --db postgres:postgrespassword@postgres:5432/postgres -s kafka:9092 diff --git a/proxy-ssl/nginx.conf b/proxy-ssl/nginx.conf index cb2ef2d48..bf95a8e8c 100644 --- a/proxy-ssl/nginx.conf +++ b/proxy-ssl/nginx.conf @@ -14,28 +14,28 @@ http { ssl_certificate_key /etc/nginx/ssl/privkey.pem; location ^~/rest/ { - proxy_pass http://172.18.0.15:1317/; + proxy_pass http://query-node:1317/; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } location ^~/rpc/ { - proxy_pass http://172.18.0.15:26657/; + proxy_pass http://query-node:26657/; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } location ^~/hasura/ { - proxy_pass http://172.18.0.89:5433/; + proxy_pass http://graphql-engine:5433/; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } location ^~/faucet/ { - proxy_pass http://172.18.0.17:5005/; + proxy_pass http://bandchain_faucet:5005/; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; @@ -48,7 +48,7 @@ http { ssl_certificate_key /etc/nginx/ssl/privkey.pem; location ^~/grpc/ { - grpc_pass grpc://172.18.0.15:9090; + grpc_pass grpc://query-node:9090; } } } diff --git a/proxy/default.vcl b/proxy/default.vcl index 050413997..3849fae27 100644 --- a/proxy/default.vcl +++ b/proxy/default.vcl @@ -1,22 +1,22 @@ vcl 4.0; backend rest { - .host = "172.18.0.15"; + .host = "query-node"; .port = "1317"; } backend bandsv { - .host = "172.18.0.15"; + .host = "query-node"; .port = "8080"; } backend hasura { - .host = "172.18.0.89"; + .host = "graphql-engine"; .port = "5433"; } backend faucet { - .host = "172.18.0.17"; + .host = "bandchain_faucet"; .port = "5005"; } From a55049170dd6c237087236303f706af31b1afa69 Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Fri, 17 Mar 2023 14:14:37 +0700 Subject: [PATCH 06/13] add useful command --- docker-config/start_docker.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-config/start_docker.sh b/docker-config/start_docker.sh index 7104ad257..bc68ca25c 100755 --- a/docker-config/start_docker.sh +++ b/docker-config/start_docker.sh @@ -1,5 +1,8 @@ #!/bin/bash +source ~/.profile +# docker rm --force $(docker ps -a -q) + DIR=`dirname "$0"` # remove old genesis From f49667f163e972d999bb6f947943527c0c838c42 Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Fri, 17 Mar 2023 14:34:27 +0700 Subject: [PATCH 07/13] adjust flow --- docker-compose.yaml | 1 - docker-config/start_docker.sh | 45 ++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 9f600e764..f75e8fe3a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -133,4 +133,3 @@ services: networks: bandchain: - driver: default diff --git a/docker-config/start_docker.sh b/docker-config/start_docker.sh index bc68ca25c..5036bce39 100755 --- a/docker-config/start_docker.sh +++ b/docker-config/start_docker.sh @@ -109,6 +109,28 @@ bandd collect-gentxs cp ~/.band/config/genesis.json $DIR/genesis.json sed -i -e 's/\"allow_messages\":.*/\"allow_messages\": [\"\/cosmos.authz.v1beta1.MsgExec\", \"\/cosmos.authz.v1beta1.MsgGrant\", \"\/cosmos.authz.v1beta1.MsgRevoke\", \"\/cosmos.bank.v1beta1.MsgSend\", \"\/cosmos.bank.v1beta1.MsgMultiSend\", \"\/cosmos.distribution.v1beta1.MsgSetWithdrawAddress\", \"\/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission\", \"\/cosmos.distribution.v1beta1.MsgFundCommunityPool\", \"\/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward\", \"\/cosmos.feegrant.v1beta1.MsgGrantAllowance\", \"\/cosmos.feegrant.v1beta1.MsgRevokeAllowance\", \"\/cosmos.gov.v1beta1.MsgVoteWeighted\", \"\/cosmos.gov.v1beta1.MsgSubmitProposal\", \"\/cosmos.gov.v1beta1.MsgDeposit\", \"\/cosmos.gov.v1beta1.MsgVote\", \"\/cosmos.staking.v1beta1.MsgEditValidator\", \"\/cosmos.staking.v1beta1.MsgDelegate\", \"\/cosmos.staking.v1beta1.MsgUndelegate\", \"\/cosmos.staking.v1beta1.MsgBeginRedelegate\", \"\/cosmos.staking.v1beta1.MsgCreateValidator\", \"\/cosmos.vesting.v1beta1.MsgCreateVestingAccount\", \"\/ibc.applications.transfer.v1.MsgTransfer\"]/g' $DIR/genesis.json +# Create faucet container +rm -rf ~/.faucet +faucet config chain-id bandchain +faucet config node tcp://host.docker.internal:26657 +faucet config port 5005 +for i in $(eval echo {1..5}) +do + # add worker key + faucet keys add worker$i + + # send band tokens to worker + echo "y" | bandd tx bank send requester $(faucet keys show worker$i) 1000000000000uband --keyring-backend test --chain-id bandchain -b block + + # wait for addding reporter transaction success + sleep 2 +done + +docker create --network chain_bandchain --name bandchain_faucet -p 5005:5005 band-validator:latest faucet r +docker cp ~/.faucet bandchain_faucet:/root/.faucet +docker start bandchain_faucet + +# Build docker-compose up -d --build sleep 10 @@ -117,7 +139,7 @@ for v in {1..4} do rm -rf ~/.yoda yoda config chain-id bandchain - yoda config node tcp://localhost:26657 + yoda config node tcp://multi-validator$v-node:26657 yoda config validator $(bandd keys show validator$v -a --bech val --keyring-backend test) yoda config executor "rest:https://asia-southeast2-band-playground.cloudfunctions.net/test-runtime-executor?timeout=10s" @@ -149,24 +171,3 @@ do docker cp ~/.yoda bandchain_oracle${v}:/root/.yoda docker start bandchain_oracle${v} done - -# Create faucet container -rm -rf ~/.faucet -faucet config chain-id bandchain -faucet config node tcp://localhost:26657 -faucet config port 5005 -for i in $(eval echo {1..5}) -do - # add worker key - faucet keys add worker$i - - # send band tokens to worker - echo "y" | bandd tx bank send requester $(faucet keys show worker$i) 1000000000000uband --keyring-backend test --chain-id bandchain -b block - - # wait for addding reporter transaction success - sleep 2 -done - -docker create --network chain_bandchain --name bandchain_faucet -p 5005:5005 band-validator:latest faucet r -docker cp ~/.faucet bandchain_faucet:/root/.faucet -docker start bandchain_faucet From 9f73f8deaf2d355f7bece62ac9e86a9062d0b9c0 Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Fri, 17 Mar 2023 14:36:51 +0700 Subject: [PATCH 08/13] adjust flow --- docker-config/start_docker.sh | 42 +++++++++++++++++------------------ proxy-ssl/nginx.conf | 2 +- proxy/default.vcl | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docker-config/start_docker.sh b/docker-config/start_docker.sh index 5036bce39..b1f3adfe0 100755 --- a/docker-config/start_docker.sh +++ b/docker-config/start_docker.sh @@ -109,27 +109,6 @@ bandd collect-gentxs cp ~/.band/config/genesis.json $DIR/genesis.json sed -i -e 's/\"allow_messages\":.*/\"allow_messages\": [\"\/cosmos.authz.v1beta1.MsgExec\", \"\/cosmos.authz.v1beta1.MsgGrant\", \"\/cosmos.authz.v1beta1.MsgRevoke\", \"\/cosmos.bank.v1beta1.MsgSend\", \"\/cosmos.bank.v1beta1.MsgMultiSend\", \"\/cosmos.distribution.v1beta1.MsgSetWithdrawAddress\", \"\/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission\", \"\/cosmos.distribution.v1beta1.MsgFundCommunityPool\", \"\/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward\", \"\/cosmos.feegrant.v1beta1.MsgGrantAllowance\", \"\/cosmos.feegrant.v1beta1.MsgRevokeAllowance\", \"\/cosmos.gov.v1beta1.MsgVoteWeighted\", \"\/cosmos.gov.v1beta1.MsgSubmitProposal\", \"\/cosmos.gov.v1beta1.MsgDeposit\", \"\/cosmos.gov.v1beta1.MsgVote\", \"\/cosmos.staking.v1beta1.MsgEditValidator\", \"\/cosmos.staking.v1beta1.MsgDelegate\", \"\/cosmos.staking.v1beta1.MsgUndelegate\", \"\/cosmos.staking.v1beta1.MsgBeginRedelegate\", \"\/cosmos.staking.v1beta1.MsgCreateValidator\", \"\/cosmos.vesting.v1beta1.MsgCreateVestingAccount\", \"\/ibc.applications.transfer.v1.MsgTransfer\"]/g' $DIR/genesis.json -# Create faucet container -rm -rf ~/.faucet -faucet config chain-id bandchain -faucet config node tcp://host.docker.internal:26657 -faucet config port 5005 -for i in $(eval echo {1..5}) -do - # add worker key - faucet keys add worker$i - - # send band tokens to worker - echo "y" | bandd tx bank send requester $(faucet keys show worker$i) 1000000000000uband --keyring-backend test --chain-id bandchain -b block - - # wait for addding reporter transaction success - sleep 2 -done - -docker create --network chain_bandchain --name bandchain_faucet -p 5005:5005 band-validator:latest faucet r -docker cp ~/.faucet bandchain_faucet:/root/.faucet -docker start bandchain_faucet - # Build docker-compose up -d --build @@ -171,3 +150,24 @@ do docker cp ~/.yoda bandchain_oracle${v}:/root/.yoda docker start bandchain_oracle${v} done + +# Create faucet container +rm -rf ~/.faucet +faucet config chain-id bandchain +faucet config node tcp://query-node:26657 +faucet config port 5005 +for i in $(eval echo {1..5}) +do + # add worker key + faucet keys add worker$i + + # send band tokens to worker + echo "y" | bandd tx bank send requester $(faucet keys show worker$i) 1000000000000uband --keyring-backend test --chain-id bandchain -b block + + # wait for addding reporter transaction success + sleep 2 +done + +docker create --network chain_bandchain --name bandchain_faucet -p 5005:5005 band-validator:latest faucet r +docker cp ~/.faucet bandchain_faucet:/root/.faucet +docker start bandchain_faucet diff --git a/proxy-ssl/nginx.conf b/proxy-ssl/nginx.conf index bf95a8e8c..6385015d3 100644 --- a/proxy-ssl/nginx.conf +++ b/proxy-ssl/nginx.conf @@ -35,7 +35,7 @@ http { } location ^~/faucet/ { - proxy_pass http://bandchain_faucet:5005/; + proxy_pass http://host.docker.internal:5005/; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; diff --git a/proxy/default.vcl b/proxy/default.vcl index 3849fae27..8712e2f33 100644 --- a/proxy/default.vcl +++ b/proxy/default.vcl @@ -16,7 +16,7 @@ backend hasura { } backend faucet { - .host = "bandchain_faucet"; + .host = "host.docker.internal"; .port = "5005"; } From cf6339fcd2b5e6936c54362f5fa6104141e81680 Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Fri, 17 Mar 2023 15:05:44 +0700 Subject: [PATCH 09/13] add restart for proxy --- docker-compose.yaml | 4 ++++ proxy-ssl/nginx.conf | 2 +- proxy/default.vcl | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f75e8fe3a..307738316 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -48,6 +48,7 @@ services: build: context: ./proxy image: proxy-server:latest + restart: always networks: - bandchain depends_on: @@ -59,6 +60,7 @@ services: build: context: ./proxy-ssl image: proxy-ssl-server:latest + restart: always networks: - bandchain depends_on: @@ -133,3 +135,5 @@ services: networks: bandchain: + + diff --git a/proxy-ssl/nginx.conf b/proxy-ssl/nginx.conf index 6385015d3..bf95a8e8c 100644 --- a/proxy-ssl/nginx.conf +++ b/proxy-ssl/nginx.conf @@ -35,7 +35,7 @@ http { } location ^~/faucet/ { - proxy_pass http://host.docker.internal:5005/; + proxy_pass http://bandchain_faucet:5005/; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; diff --git a/proxy/default.vcl b/proxy/default.vcl index 8712e2f33..3849fae27 100644 --- a/proxy/default.vcl +++ b/proxy/default.vcl @@ -16,7 +16,7 @@ backend hasura { } backend faucet { - .host = "host.docker.internal"; + .host = "bandchain_faucet"; .port = "5005"; } From 117f7ae2a3c1f9bb5d0f2c982d0e0cd142739e14 Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Fri, 17 Mar 2023 15:25:39 +0700 Subject: [PATCH 10/13] change port --- proxy-ssl/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy-ssl/nginx.conf b/proxy-ssl/nginx.conf index bf95a8e8c..530aac2b3 100644 --- a/proxy-ssl/nginx.conf +++ b/proxy-ssl/nginx.conf @@ -28,7 +28,7 @@ http { } location ^~/hasura/ { - proxy_pass http://graphql-engine:5433/; + proxy_pass http://graphql-engine:8080/; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; From 5a9349cc8aee37cf86f13e3fb2c0bf0601d9ad94 Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Fri, 17 Mar 2023 16:48:48 +0700 Subject: [PATCH 11/13] reduce block time --- docker-config/run.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker-config/run.sh b/docker-config/run.sh index fdee42249..2157da075 100755 --- a/docker-config/run.sh +++ b/docker-config/run.sh @@ -7,6 +7,10 @@ cp /chain/docker-config/$1/node_key.json ~/.band/config/node_key.json cp /chain/docker-config/genesis.json ~/.band/config/genesis.json cp -r /chain/docker-config/files ~/.band +sed -E -i \ + "s/timeout_commit = \".*\"/timeout_commit = \"3s\"/" \ + ~/.band/config/config.toml + if [ "$1" == "query-node" ];then cp /chain/docker-config/app.toml ~/.band/config/app.toml fi From dd9254c8cb5a4a1917ac02751f8b97e91eea91a4 Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Fri, 17 Mar 2023 17:14:55 +0700 Subject: [PATCH 12/13] fixed path --- proxy-ssl/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy-ssl/nginx.conf b/proxy-ssl/nginx.conf index 530aac2b3..87f110d0a 100644 --- a/proxy-ssl/nginx.conf +++ b/proxy-ssl/nginx.conf @@ -47,7 +47,7 @@ http { ssl_certificate /etc/nginx/ssl/cert.pem; ssl_certificate_key /etc/nginx/ssl/privkey.pem; - location ^~/grpc/ { + location / { grpc_pass grpc://query-node:9090; } } From dfd54e7212565756f9ed40c30ca3e2a47acafd26 Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Mon, 17 Apr 2023 19:52:09 +0700 Subject: [PATCH 13/13] add condition --- flusher/flusher/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flusher/flusher/handler.py b/flusher/flusher/handler.py index d41ca19ab..cf247aece 100644 --- a/flusher/flusher/handler.py +++ b/flusher/flusher/handler.py @@ -73,7 +73,7 @@ def handle_new_block(self, msg): self.conn.execute(blocks.insert(), msg) def handle_new_transaction(self, msg): - msg["fee_payer"] = msg["fee_payer"] if len(msg["fee_payer"]) else None + msg["fee_payer"] = msg["fee_payer"] if "fee_payer" in msg and len(msg["fee_payer"]) else None self.conn.execute( insert(transactions).values(**msg).on_conflict_do_update(constraint="transactions_pkey", set_=msg) )