Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Spit and polish
  • Loading branch information
rozhkovdmitrii committed Feb 10, 2022
commit 67066fd6209549d5cdc5c4ee9b6d043e7f6a490d
3 changes: 2 additions & 1 deletion proxy/run-indexer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
echo $(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ Indexer:Undefined {}
COMPONENT=Proxy
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Start ${COMPONENT} service"

if [ -z "$EVM_LOADER" ]; then
echo "Extracting EVM_LOADER address from keypair file..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to change logging format here too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I looked at this line, Ivan
It doesn't have any heavy operation after previous logging note. That's why I left it as it is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Expand Down
7 changes: 4 additions & 3 deletions proxy/run-proxy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
echo $(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ Proxy:Undefined {}
COMPONENT=Proxy
echo "$(date "+%F %X.%3N") I $(basename $0):${LINENO} $$ ${COMPONENT}:StartScript {} Start ${COMPONENT} service"

source proxy/run-set-env.sh
source proxy/run-set-env.sh ${COMPONENT}

echo run-proxy
echo "$(date "+%F %X.%3N") I $(basename $0):${LINENO} $$ ${COMPONENT}:StartScript {} run-proxy"
python3 -m proxy --hostname 0.0.0.0 --port 9090 --enable-web-server --plugins proxy.plugin.SolanaProxyPlugin $EXTRA_ARGS
8 changes: 4 additions & 4 deletions proxy/run-set-env.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

COMPONENT=$1
set -xeo pipefail

date
echo $(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} "Init environment set"

if [ "$CONFIG" == "ci" ]; then
[[ -z "$SOLANA_URL" ]] && export SOLANA_URL="http://solana:8899"
Expand Down Expand Up @@ -59,8 +59,8 @@ elif [ "$CONFIG" != "custom" ]; then
exit 1
fi

[[ -z "$SOLANA_URL" ]] && echo "SOLANA_URL is not set" && exit 1
[[ -z "$EVM_LOADER" ]] && echo "EVM_LOADER is not set" && exit 1
[[ -z "$SOLANA_URL" ]] && echo "$(date "+%F %X.%3N") E $(basename $0):${LINENO} $$ ${COMPONENT}:StartScript {} SOLANA_URL is not set" && exit 1
[[ -z "$EVM_LOADER" ]] && echo "$(date "+%F %X.%3N") E $(basename $0):${LINENO} $$ ${COMPONENT}:StartScript {} EVM_LOADER is not set" && exit 1

solana config set -u $SOLANA_URL

Expand Down
14 changes: 8 additions & 6 deletions proxy/run-test-proxy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
echo $(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ Proxy:Undefined {}
COMPONENT=Proxy
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Start ${COMPONENT} service"

if [ -z "$SOLANA_URL" ]; then
echo "SOLANA_URL is not set"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Expand All @@ -8,17 +9,18 @@ fi

solana config set -u $SOLANA_URL

echo "Dumping evm_loader and extracting ELF parameters"
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Dumping evm_loader and extracting ELF parameters"
export EVM_LOADER=$(solana address -k /spl/bin/evm_loader-keypair.json)
export $(/spl/bin/neon-cli --commitment confirmed --url $SOLANA_URL --evm_loader="$EVM_LOADER" neon-elf-params)

export NUM_ACCOUNTS=15
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Create test accounts: ${NUM_ACCOUNTS}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need to log here because this message will duplicate one produced by create-test-accounts.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/spl/bin/create-test-accounts.sh $NUM_ACCOUNTS

[[ -z "$NEW_USER_AIRDROP_AMOUNT" ]] && export NEW_USER_AIRDROP_AMOUNT=100
echo "NEW_USER_AIRDROP_AMOUNT=$NEW_USER_AIRDROP_AMOUNT"
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} NEW_USER_AIRDROP_AMOUNT=${NEW_USER_AIRDROP_AMOUNT}"

echo "NEON_TOKEN_MINT=$NEON_TOKEN_MINT"
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} NEON_TOKEN_MINT=${NEON_TOKEN_MINT}"

for i in $(seq 1 $NUM_ACCOUNTS); do
ID_FILE="$HOME/.config/solana/id"
Expand All @@ -29,9 +31,9 @@ for i in $(seq 1 $NUM_ACCOUNTS); do
fi

if [ "$(spl-token balance --owner "$ID_FILE" "$NEON_TOKEN_MINT" || echo '0')" == "0" ]; then
echo 'Create balance and mint token'
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Create balance and mint token"
TOKEN_ACCOUNT=$( (spl-token create-account --owner "$ID_FILE" "$NEON_TOKEN_MINT" || true) | grep -Po 'Creating account \K[^\n]*')
echo "TOKEN_ACCOUNT=$TOKEN_ACCOUNT"
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} TOKEN_ACCOUNT=$TOKEN_ACCOUNT"
spl-token mint "$NEON_TOKEN_MINT" $(("$NEW_USER_AIRDROP_AMOUNT"*100000)) --owner /spl/bin/evm_loader-keypair.json -- "$TOKEN_ACCOUNT"
fi
done
Expand Down
7 changes: 4 additions & 3 deletions run-airdropper.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
echo $(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ Airdropper:Undefined {}
COMPONENT=Airdropper
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Start ${COMPONENT} service"

if [ -z "$EVM_LOADER" ]; then
echo "Extracting EVM_LOADER address from keypair file..."
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Extracting EVM_LOADER address from keypair file..."
export EVM_LOADER=$(solana address -k /spl/bin/evm_loader-keypair.json)
echo "EVM_LOADER=$EVM_LOADER"
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} EVM_LOADER=$EVM_LOADER"
fi
export AIRDROPPER_MODE='true'
[[ -z "$FINALIZED" ]] && export FINALIZED="confirmed"
Expand Down
10 changes: 5 additions & 5 deletions run-faucet.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/bin/sh
echo $(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ Faucet:Undefined {}

COMPONENT=Faucet
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Start ${COMPONENT} service"
if [ -z "$SOLANA_URL" ]; then
echo "SOLANA_URL is not set"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change format too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

exit 1
fi

echo "Extracting NEON-EVM's ELF parameters"
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Extracting NEON-EVM's ELF parameters"
export EVM_LOADER=$(solana address -k /spl/bin/evm_loader-keypair.json)
export $(/spl/bin/neon-cli --commitment confirmed --url $SOLANA_URL --evm_loader="$EVM_LOADER" neon-elf-params)

BALANCE=$(solana balance | tr '.' '\t'| tr '[:space:]' '\t' | cut -f1)
if [ "$BALANCE" -eq 0 ]; then
echo "SOL balance is 0"
echo "$(date "+%F %X.%3N") W $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} SOL balance is 0"
exit 1
fi

if [ "$(spl-token balance "$NEON_TOKEN_MINT" || echo 0)" -eq 0 ]; then
echo "NEON balance is 0"
echo "$(date "+%F %X.%3N") W $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} NEON balance is 0"
exit 1
fi

Expand Down
3 changes: 2 additions & 1 deletion run-test-airdropper.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
echo $(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ Airdropper:Undefined {}
COMPONENT=Airdropper
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Start ${COMPONENT} service"

[[ -z "$FINALIZED" ]] && export FINALIZED="confirmed"
export EVM_LOADER=$(solana address -k /spl/bin/evm_loader-keypair.json)
Expand Down
15 changes: 8 additions & 7 deletions run-test-faucet.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
#!/bin/bash
echo $(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ Faucet:Undefined {}
COMPONENT=Faucet
echo "$(date "+%F %X.%3N") I $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Start ${COMPONENT} service"

if [ -z "$SOLANA_URL" ]; then
echo "SOLANA_URL is not set"
echo "$(date "+%F %X.%3N") E $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} SOLANA_URL is not set"
exit 1
fi

if [ -z "$TEST_FAUCET_INIT_NEON_BALANCE" ]; then
echo "TEST_FAUCET_INIT_NEON_BALANCE is not set"
echo "$(date "+%F %X.%3N") E $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} TEST_FAUCET_INIT_NEON_BALANCE is not set"
exit 1
fi

solana config set -u "$SOLANA_URL"

echo "Extracting NEON-EVM's ELF parameters"
echo "$(date "+%F %X.%3N") E $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Extracting NEON-EVM's ELF parameters"
export EVM_LOADER=$(solana address -k /spl/bin/evm_loader-keypair.json)
export $(/spl/bin/neon-cli --commitment confirmed --url $SOLANA_URL --evm_loader="$EVM_LOADER" neon-elf-params)

echo "Generating new account for operate with faucet service"
echo "$(date "+%F %X.%3N") E $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Generating new account for operate with faucet service"
rm /$HOME/.config/solana/id.json
/spl/bin/create-test-accounts.sh 1

if [ "$(spl-token balance "$NEON_TOKEN_MINT" || echo 0)" -eq 0 ]; then
echo 'Create balance and mint token'
echo "$(date "+%F %X.%3N") E $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} Create balance and mint token"
TOKEN_ACCOUNT=$( (spl-token create-account "$NEON_TOKEN_MINT" || true) | grep -Po 'Creating account \K[^\n]*')
echo "TOKEN_ACCOUNT=$TOKEN_ACCOUNT"
echo "$(date "+%F %X.%3N") E $(basename "$0"):${LINENO} $$ ${COMPONENT}:StartScript {} TOKEN_ACCOUNT=$TOKEN_ACCOUNT"
spl-token mint "$NEON_TOKEN_MINT" $TEST_FAUCET_INIT_NEON_BALANCE --owner /spl/bin/evm_loader-keypair.json -- "$TOKEN_ACCOUNT"
fi

Expand Down