From ea816a655b04ad1c12952914bcf0f48153ca7df4 Mon Sep 17 00:00:00 2001 From: cosmatudor Date: Mon, 9 Dec 2024 18:41:42 +0200 Subject: [PATCH 1/4] add new docker-compose file --- docker/docker-compose.yaml | 0 docker/scripts/send-tx.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 docker/docker-compose.yaml create mode 100644 docker/scripts/send-tx.sh diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 00000000..e69de29b diff --git a/docker/scripts/send-tx.sh b/docker/scripts/send-tx.sh new file mode 100644 index 00000000..e69de29b From dceaaf694325a965682716c4162125d5f90f8680 Mon Sep 17 00:00:00 2001 From: cosmatudor Date: Mon, 9 Dec 2024 18:44:52 +0200 Subject: [PATCH 2/4] add new docker-compose yaml --- docker/docker-compose.yaml | 140 +++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index e69de29b..c2b9d670 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -0,0 +1,140 @@ +version: "3.9" + +services: + rabbitmq: + ports: + - 127.0.0.1:5672:5672 + - 127.0.0.1:15672:15672 + container_name: rabbitmq-container + image: "rabbitmq:3-management" + healthcheck: + test: rabbitmq-diagnostics -q ping + interval: 10s + timeout: 5s + retries: 5 + + redis: + image: "redis:alpine" + command: redis-server + ports: + - "127.0.0.1:6379:6379" + environment: + - REDIS_REPLICATION_MODE=master + + events-notifier: + container_name: events-notifier-container + image: multiversx/events-notifier:latest + depends_on: + rabbitmq: + condition: service_healthy + entrypoint: > + /bin/bash -c "apt-get update && apt-get install curl -y + && sed -i '/Enabled will determine if websocket connector will be enabled or not/{n;s/Enabled = false/Enabled = true/}' ./config/config.toml + && sed -i 's|localhost:22111|0.0.0.0:22111|g' ./config/config.toml + && sed -i 's|localhost:6379|redis:6379|g' ./config/config.toml + && sed -i 's|amqp://guest:guest@localhost:5672|amqp://guest:guest@rabbitmq:5672|g' ./config/config.toml + && cat ./config/config.toml + && ./notifier --check-duplicates=false --api-type=rabbit-api" + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:5000/status/metrics"] + interval: 10s + timeout: 5s + retries: 5 + + elasticsearch: + ports: + - 127.0.0.1:9200:9200 + container_name: elasticsearch-container + image: docker.elastic.co/elasticsearch/elasticsearch:7.16.1 + environment: + - "discovery.type=single-node" + - "xpack.security.enabled=false" + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + ulimits: + memlock: + soft: -1 + hard: -1 + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:9200"] + interval: 10s + timeout: 5s + retries: 5 + + # TODO use the websockets based elastic indexer when the communication problems are solved + elastic-indexer: + #ports: 22112 + container_name: elastic-indexer + image: multiversx/elastic-indexer:latest + depends_on: + elasticsearch: + condition: service_healthy + entrypoint: > + /bin/bash -c "sed -i 's|http://localhost:9200|http://elasticsearch:9200|g' ./config/prefs.toml + && sed -i 's|url = \"localhost:22111\"|url = \"0.0.0.0:22111\"|g' ./config/prefs.toml + && cat ./config/prefs.toml + && ./elasticindexer -log-level *:DEBUG" + + chain-simulator: + container_name: chain-simulator + ports: + - 8085:8085 + image: multiversx/chainsimulator:latest + environment: + EVENTS_NOTIFIER_URL: 'ws://events-notifier:22111' + ELASTIC_SEARCH_URL: 'elasticsearch:9200' # just a dummy string for now + depends_on: + elasticsearch: + condition: service_healthy + events-notifier: + condition: service_healthy + entrypoint: > + /bin/bash -c " sed -i 's|http://localhost:9200|http://elasticsearch:9200|g' ./config/node/config/external.toml + && ./start-with-services.sh -log-level *:INFO" + healthcheck: + test: [ "CMD", "curl", "-f", "http://127.0.0.1:8085/simulator/observers" ] + interval: 10s + timeout: 5s + retries: 5 + + api: + ports: + - 127.0.0.1:3001:3001 + container_name: api + image: multiversx/mx-api-service:test1 + environment: + MVX_ENV: devnet + REDIS_IP: redis + GATEWAY_URL: http://chain-simulator:8085 + ELASTICSEARCH_URL: http://elasticsearch:9200 + depends_on: + elasticsearch: + condition: service_healthy + redis: + condition: service_started + + explorer: + ports: + - 3002:80 + container_name: explorer + image: multiversx/mx-explorer-dapp:main + environment: + START_NAME_STOP: devnet + START_CHAIN_ID_STOP: D + START_EGLD_LABEL_STOP: xEGLD + START_WALLET_ADDRESS_STOP: https://devnet-wallet.multiversx.com + START_EXPLORER_ADDRESS_STOP: https://devnet-explorer.multiversx.com + START_NFT_EXPLORER_ADDRESS_STOP: https://devnet.xspotlight.com + START_API_ADDRESS_STOP: http://127.0.0.1:3001 + + lite-wallet: + ports: + - 3003:80 + container_name: lite-wallet + image: multiversx/mx-lite-wallet-dapp:main + environment: + START_NETWORK_ID_STOP: custom + START_NETWORK_NAME_STOP: custom + START_API_ADDRESS_STOP: http://127.0.0.1:3001 + START_GATEWAY_URL_STOP: http://127.0.0.1:8085 + START_WALLET_ADDRESS_STOP: https://testnet-wallet.multiversx.com + START_WEGLD_ID_STOP: xEGLD From 1a7f09ef6fa062cc2aa98e41b04ca3cea1772bd1 Mon Sep 17 00:00:00 2001 From: cosmatudor Date: Mon, 9 Dec 2024 18:45:43 +0200 Subject: [PATCH 3/4] add send-tx script --- docker/scripts/send-tx.sh | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/docker/scripts/send-tx.sh b/docker/scripts/send-tx.sh index e69de29b..1455196e 100644 --- a/docker/scripts/send-tx.sh +++ b/docker/scripts/send-tx.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Call the endpoint and store the response in a variable +response=$(curl -s "http://localhost:8085/simulator/initial-wallets") + +# Use jq to extract the "bech32" address from the JSON response +bech32_address=$(echo "$response" | jq -r '.data.balanceWallets | to_entries[0].value.address.bech32') + +# Print the address to verify it was extracted correctly +echo "Extracted Bech32 Address: $bech32_address" + +# Get account information +account_info_response=$(curl -s --request GET \ + --url "http://localhost:8085/address/$bech32_address" \ + --header 'User-Agent: insomnia/10.0.0') + +# Print the response for debugging +echo "Account info response: $account_info_response" + +# Step 2: Extract the nonce using jq +nonce=$(echo "$account_info_response" | jq -r '.data.account.nonce') + +# Check if nonce is not empty +if [ -n "$nonce" ]; then + echo "Extracted nonce: $nonce" +else + echo "Error: No nonce found in the account info response." + exit 1 +fi + +tx_send_response=$(curl -s --request POST \ + --url http://localhost:8085/transaction/send \ + --header 'Content-Type: application/json' \ + --header 'User-Agent: insomnia/10.0.0' \ + --data '{ + "nonce": '$nonce', + "value": "50000000000000000000", + "sender": "'$bech32_address'", + "receiver": "erd12js50s7ycclwpac4qpx7lty3prhpu8hy00thjgz9f67p33w7m94qmzttem", + "gasLimit": 50000, + "gasPrice": 1000000000, + "chainId": "chain", + "signature": "aa", + "version": 1 +}') + +echo $tx_send_response + +# Extract txHash using jq +tx_hash=$(echo "$tx_send_response" | jq -r '.data.txHash') + +# Print the extracted txHash +echo "Extracted txHash: $tx_hash" + +sleep 2 + +# Make the second call to generate blocks until the transaction is processed +generate_blocks_response=$(curl -s --request POST \ + --url "http://localhost:8085/simulator/generate-blocks-until-transaction-processed/$tx_hash" \ + --header 'Content-Type: application/json' \ + --header 'User-Agent: insomnia/10.0.0') + +# Print the response from the second call +echo "Response from generate blocks: $generate_blocks_response" From da0a18cb365955c3a3887cd13cd3bdd35ce64bf8 Mon Sep 17 00:00:00 2001 From: cosmatudor Date: Tue, 10 Dec 2024 11:08:00 +0200 Subject: [PATCH 4/4] deleted script --- docker/scripts/send-tx.sh | 64 --------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 docker/scripts/send-tx.sh diff --git a/docker/scripts/send-tx.sh b/docker/scripts/send-tx.sh deleted file mode 100644 index 1455196e..00000000 --- a/docker/scripts/send-tx.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# Call the endpoint and store the response in a variable -response=$(curl -s "http://localhost:8085/simulator/initial-wallets") - -# Use jq to extract the "bech32" address from the JSON response -bech32_address=$(echo "$response" | jq -r '.data.balanceWallets | to_entries[0].value.address.bech32') - -# Print the address to verify it was extracted correctly -echo "Extracted Bech32 Address: $bech32_address" - -# Get account information -account_info_response=$(curl -s --request GET \ - --url "http://localhost:8085/address/$bech32_address" \ - --header 'User-Agent: insomnia/10.0.0') - -# Print the response for debugging -echo "Account info response: $account_info_response" - -# Step 2: Extract the nonce using jq -nonce=$(echo "$account_info_response" | jq -r '.data.account.nonce') - -# Check if nonce is not empty -if [ -n "$nonce" ]; then - echo "Extracted nonce: $nonce" -else - echo "Error: No nonce found in the account info response." - exit 1 -fi - -tx_send_response=$(curl -s --request POST \ - --url http://localhost:8085/transaction/send \ - --header 'Content-Type: application/json' \ - --header 'User-Agent: insomnia/10.0.0' \ - --data '{ - "nonce": '$nonce', - "value": "50000000000000000000", - "sender": "'$bech32_address'", - "receiver": "erd12js50s7ycclwpac4qpx7lty3prhpu8hy00thjgz9f67p33w7m94qmzttem", - "gasLimit": 50000, - "gasPrice": 1000000000, - "chainId": "chain", - "signature": "aa", - "version": 1 -}') - -echo $tx_send_response - -# Extract txHash using jq -tx_hash=$(echo "$tx_send_response" | jq -r '.data.txHash') - -# Print the extracted txHash -echo "Extracted txHash: $tx_hash" - -sleep 2 - -# Make the second call to generate blocks until the transaction is processed -generate_blocks_response=$(curl -s --request POST \ - --url "http://localhost:8085/simulator/generate-blocks-until-transaction-processed/$tx_hash" \ - --header 'Content-Type: application/json' \ - --header 'User-Agent: insomnia/10.0.0') - -# Print the response from the second call -echo "Response from generate blocks: $generate_blocks_response"