Skip to content

Commit

Permalink
Merge branch 'main' into golint
Browse files Browse the repository at this point in the history
  • Loading branch information
akremstudy committed May 30, 2024
2 parents 8b9a2d8 + 5784f6e commit 2f58ade
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 14 deletions.
6 changes: 3 additions & 3 deletions daemons/reporter/client/current_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ func (c *Client) CurrentQuery(ctx context.Context) ([]byte, error) {
if err != nil {
return nil, fmt.Errorf("error calling 'CurrentCyclelistQuery': %w", err)
}
qid, err := utils.QueryIDFromDataString(response.QueryData)
querydata, err := utils.QueryBytesFromString(response.QueryData)
if err != nil {
return nil, fmt.Errorf("error parsing query id from response: %w", err)
}

c.logger.Info("ReporterDaemon", "next query id in cycle list", hex.EncodeToString(qid))
return qid, nil
c.logger.Info("ReporterDaemon", "next query id in cycle list", hex.EncodeToString(querydata))
return querydata, nil
}
103 changes: 103 additions & 0 deletions layer_scripts/join_chain_new_node_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash

# clear the terminal
clear

# Stop execution if any command fails
set -e

KEYRING_BACKEND="test"
PASSWORD="password"
NODE_MONIKER="billmoniker"
NODE_NAME="bill"

export LAYERD_NODE_HOME="$HOME/.layer/$NODE_NAME"
## YOU WILL NEED TO SET THIS TO WHATEVER NODE YOU WOULD LIKE TO USE
export LAYER_NODE_URL=

# Remove old test chain data (if present)
echo "Removing old test chain data..."
rm -rf ~/.layer

# Build layerd
echo "Building layerd..."
go build ./cmd/layerd

# Initialize the chain
echo "Initializing the chain..."
./layerd init layer --chain-id layer

# Initialize chain node with the folder for node
echo "Initializing chain node for node..."
./layerd init $NODE_MONIKER --chain-id layer --home ~/.layer/$NODE_NAME

# # Add a validator account for node
echo "Creating account keys for node to be able to send and receive loya and stake..."
./layerd keys add $NODE_NAME --keyring-backend $KEYRING_BACKEND --home ~/.layer/$NODE_NAME

echo "Change denom to loya in config files..."
sed -i 's/([0-9]+)stake/1loya/g' ~/.layer/$NODE_NAME/config/app.toml
sed -i 's/([0-9]+)stake/1loya/g' ~/.layer/config/app.toml

echo "Set Chain Id to layer in client config file..."
sed -i 's/^chain-id = .*$/chain-id = "layer"/g' ~/.layer/$NODE_NAME/config/app.toml
sed -i 's/^chain-id = .*$/chain-id = "layer"/g' ~/.layer/config/app.toml

# Get address/account for node to use in gentx tx
echo "Get address/account for node"
NODE=$(./layerd keys show $NODE_NAME -a --keyring-backend $KEYRING_BACKEND --home ~/.layer/$NODE_NAME)
echo "NODE: $NODE"

# Modify timeout_commit in config.toml for node
echo "Modifying timeout_commit in config.toml for node..."
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/' ~/.layer/$NODE_NAME/config/config.toml

# Open up node to outside traffic
echo "Open up node to outside traffice"
sed -i 's/^laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' ~/.layer/$NODE_NAME/config/config.toml
sed -i 's/^laddr = "tcp:\/\/127.0.0.1:26656"/laddr = "tcp:\/\/0.0.0.0:26656"/g' ~/.layer/$NODE_NAME/config/config.toml

sed -i 's/^address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:1317"/g' ~/.layer/$NODE_NAME/config/app.toml

# Modify cors to accept *
echo "Modify cors to accept *"
sed -i 's/^cors_allowed_origins = \[\]/cors_allowed_origins = \["\*"\]/g' ~/.layer/$NODE_NAME/config/config.toml
sed -i 's/^cors_allowed_origins = \[\]/cors_allowed_origins = \["\*"\]/g' ~/.layer/config/config.toml

# enable unsafe cors
echo "Enable unsafe cors"
sed -i 's/^cors_allowed_origins = \[\]/cors_allowed_origins = \["\*"\]/g' ~/.layer/$NODE_NAME/config/app.toml
sed -i 's/^enable-unsafe-cors = false/enable-unsafe-cors = true/g' ~/.layer/$NODE_NAME/config/app.toml
sed -i 's/^enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' ~/.layer/config/app.toml
sed -i 's/^enable-unsafe-cors = false/enable-unsafe-cors = true/g' ~/.layer/config/app.toml

# Modify keyring-backend in client.toml for node
echo "Modifying keyring-backend in client.toml for node..."
sed -i 's/^keyring-backend = "os"/keyring-backend = "'$KEYRING_BACKEND'"/g' ~/.layer/$NODE_NAME/config/client.toml
# update for main dir as well. why is this needed?
sed -i 's/keyring-backend = "os"/keyring-backend = "'$KEYRING_BACKEND'"/g' ~/.layer/config/client.toml

rm -f ~/.layer/config/genesis.json
rm -f ~/.layer/$NODE_NAME/config/genesis.json
# get genesis file from running node's rpc
echo "Getting genesis from runnning node....."
curl $LAYER_NODE_URL:26657/genesis | jq '.result.genesis' > ~/.layer/config/genesis.json
curl $LAYER_NODE_URL:26657/genesis | jq '.result.genesis' > ~/.layer/$NODE_NAME/config/genesis.json

export QUOTED_TELLORNODE_ID="$(curl $LAYER_NODE_URL:26657/status | jq '.result.node_info.id')"
#export TELLORNODE_ID=${QUOTED_TELLORNODE_ID//\"/}
export TELLORNODE_ID=${echo "$QUOTED_TELLORNODE_ID" | tr -d "'\"" }
echo "NODE ID: $TELLORNODE_ID"
# echo "Tellor node id: $TELLORNODE_ID"
# sed -i 's/seeds = ""/seeds = "'$TELLORNODE_ID'@$LAYER_NODE_URL:26656"/g' ~/.layer/$NODE_NAME/config/config.toml
# sed -i 's/persistent_peers = ""/persistent_peers = "'$TELLORNODE_ID'@$LAYER_NODE_URL:26656"/g' ~/.layer/$NODE_NAME/config/config.toml
sed -i 's/seeds = ""/seeds = "'$TELLORNODE_ID'@'$LAYER_NODE_URL':26656"/g' ~/.layer/$NODE_NAME/config/config.toml
sed -i 's/persistent_peers = ""/persistent_peers = "'$TELLORNODE_ID'@'$LAYER_NODE_URL':26656"/g' ~/.layer/$NODE_NAME/config/config.toml

echo "Node ID: $QUOTED_TELLORNODE_ID"
echo "Path: @$LAYER_NODE_URL:26656"

sleep 60

echo "Starting chain for node..."
./layerd start --home $LAYERD_NODE_HOME --api.enable --api.swagger --panic-on-daemon-failure-enabled=false --p2p.seeds "$TELLORNODE_ID@$LAYER_NODE_URL:26656"
83 changes: 83 additions & 0 deletions layer_scripts/join_chain_new_node_mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

# clear the terminal
clear

# Stop execution if any command fails
set -e

KEYRING_BACKEND="test"
PASSWORD="password"
NODE_MONIKER="billmoniker"
NODE_NAME="bill"

export LAYERD_NODE_HOME="$HOME/.layer/$NODE_NAME"
## YOU WILL NEED TO SET THIS TO WHATEVER NODE YOU WOULD LIKE TO USE
export LAYER_NODE_URL=

# Remove old test chain data (if present)
echo "Removing old test chain data..."
rm -rf ~/.layer
rm -rf ~/.layer/$NODE_NAME

# Build layerd
echo "Building layerd..."
go build ./cmd/layerd

# Initialize the chain
echo "Initializing the chain..."
./layerd init layer --chain-id layer

# Initialize chain node with the folder for alice
echo "Initializing chain node for alice..."
./layerd init $NODE_MONIKER --chain-id layer --home ~/.layer/$NODE_NAME

echo "creating keys for node"
./layerd keys add $NODE_NAME --home ~/.layer/$NODE_NAME --keyring-backend $KEYRING_BACKEND


# Modify timeout_commit in config.toml for node
echo "Modifying timeout_commit in config.toml for $NODE_NAME..."
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/' ~/.layer/$NODE_NAME/config/config.toml

# Open up node to outside traffic
echo "Open up node to outside traffice"
sed -i '' 's/^laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' ~/.layer/$NODE_NAME/config/config.toml
sed -i '' 's/^laddr = "tcp:\/\/127.0.0.1:26656"/laddr = "tcp:\/\/0.0.0.0:26656"/g' ~/.layer/$NODE_NAME/config/config.toml

sed -i '' 's/^address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:1317"/g' ~/.layer/$NODE_NAME/config/app.toml

# Modify cors to accept *
echo "Modify cors to accept *"
sed -i '' 's/^cors_allowed_origins = \[\]/cors_allowed_origins = \["\*"\]/g' ~/.layer/$NODE_NAME/config/config.toml
sed -i '' 's/^cors_allowed_origins = \[\]/cors_allowed_origins = \["\*"\]/g' ~/.layer/config/config.toml

# enable unsafe cors
echo "Enable unsafe cors"
sed -i '' 's/^cors_allowed_origins = \[\]/cors_allowed_origins = \["\*"\]/g' ~/.layer/$NODE_NAME/config/app.toml
sed -i '' 's/^enable-unsafe-cors = false/enable-unsafe-cors = true/g' ~/.layer/$NODE_NAME/config/app.toml
sed -i '' 's/^enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' ~/.layer/config/app.toml
sed -i '' 's/^enable-unsafe-cors = false/enable-unsafe-cors = true/g' ~/.layer/config/app.toml

# Modify keyring-backend in client.toml for node
echo "Modifying keyring-backend in client.toml for node..."
sed -i '' 's/^keyring-backend = "os"/keyring-backend = "test"/g' ~/.layer/$NODE_NAME/config/client.toml
# update for main dir as well. why is this needed?
sed -i '' 's/keyring-backend = "os"/keyring-backend = "test"/g' ~/.layer/config/client.toml

rm -f ~/.layer/config/genesis.json
rm -f ~/.layer/$NODE_NAME/config/genesis.json
# get genesis file from running node's rpc
echo "Getting genesis from runnning node....."
curl $LAYER_NODE_URL:26657/genesis | jq '.result.genesis' > ~/.layer/config/genesis.json
curl $LAYER_NODE_URL:26657/genesis | jq '.result.genesis' > ~/.layer/$NODE_NAME/config/genesis.json

export QUOTED_TELLORNODE_ID="$(curl $LAYER_NODE_URL:26657/status | jq '.result.node_info.id')"
export TELLORNODE_ID=${QUOTED_TELLORNODE_ID//\"/}
echo "Tellor node id: $TELLORNODE_ID"
sed -i '' 's/seeds = ""/seeds = "'$TELLORNODE_ID'@'$LAYER_NODE_URL':26656"/g' ~/.layer/$NODE_NAME/config/config.toml
sed -i '' 's/persistent_peers = ""/persistent_peers = "'$TELLORNODE_ID'@'$LAYER_NODE_URL':26656"/g' ~/.layer/$NODE_NAME/config/config.toml


echo "Starting chain for node..."
./layerd start --home $LAYERD_NODE_HOME --api.enable --api.swagger --panic-on-daemon-failure-enabled=false --p2p.seeds "$TELLORNODE_ID@$LAYER_NODE_URL:26656"
Empty file.
4 changes: 2 additions & 2 deletions setup_docker_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ done

# rm -r -f build

# echo "Build with checksum using Makefile.."
# make build-with-checksum
echo "Build with checksum using Makefile.."
make build-with-checksum


# Build base image of layerd_i to be the image used across all containers
Expand Down
6 changes: 6 additions & 0 deletions start_scripts/start_one_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ echo "Adding validator account for alice..."
echo "charlie user..."
./layerd keys add charlie --keyring-backend $KEYRING_BACKEND --home ~/.layer/alice

# echo "creating account for faucet..."
# ./layerd keys add faucet --recover=true

# Update vote_extensions_enable_height in genesis.json for alice
echo "Updating vote_extensions_enable_height in genesis.json for alice..."
Expand All @@ -44,6 +46,10 @@ echo "Adding genesis account for alice..."
echo "charlie..."
./layerd genesis add-genesis-account $(./layerd keys show charlie -a --keyring-backend $KEYRING_BACKEND --home ~/.layer/alice) 10000000000000loya --keyring-backend $KEYRING_BACKEND --home ~/.layer/alice


# echo "Faucet..."
# ./layerd genesis add-genesis-account tellor19d90wqftqx34khmln36zjdswm9p2aqawq2t3vp 10000000000000loya --home ~/.layer/alice

# Create a tx to stake some loyas for alice
echo "Creating gentx for alice..."
./layerd genesis gentx alice 1000000loya --chain-id layer --keyring-backend $KEYRING_BACKEND --home ~/.layer/alice --keyring-dir ~/.layer/alice
Expand Down
22 changes: 13 additions & 9 deletions start_scripts/start_one_node_aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ sed -i 's/^keyring-backend = .*"/keyring-backend = "'$KEYRING_BACKEND'"/g' ~/.la
echo "Adding validator account for alice..."
./layerd keys add alice --keyring-backend $KEYRING_BACKEND --home ~/.layer/alice

echo "creating account for faucet..."
./layerd keys add faucet --recover=true --keyring-backend test

echo "set chain id in genesis file to layer..."
sed -ie 's/"chain_id": .*"/"chain_id": '\"layer\"'/g' ~/.layer/alice/config/genesis.json
sed -ie 's/"chain_id": .*"/"chain_id": '\"layer\"'/g' ~/.layer/config/genesis.json
Expand All @@ -61,9 +64,17 @@ echo "Get address/account for alice to use in gentx tx"
ALICE=$(./layerd keys show alice -a --keyring-backend $KEYRING_BACKEND --home ~/.layer/alice)
echo "ALICE: $ALICE"

# echo "Get address for faucet account..."
# FAUCET=$(./layerd keys show faucet -a )
# echo "Faucet keys: $FAUCET"

# Create a tx to give alice loyas to stake
echo "Adding genesis account for alice..."
./layerd genesis add-genesis-account $ALICE 100000000000000000loya --keyring-backend $KEYRING_BACKEND --home ~/.layer/alice
./layerd genesis add-genesis-account $ALICE 1000000000000000000000000000loya --keyring-backend $KEYRING_BACKEND --home ~/.layer/alice

# Create a tx to give faucet loyas to have on hold to give to users
echo "Adding genesis account for alice..."
./layerd genesis add-genesis-account tellor19d90wqftqx34khmln36zjdswm9p2aqawq2t3vp 1000000000000000000000000000loya --home ~/.layer/alice

# Create a tx to stake some loyas for alice
echo "Creating gentx for alice..."
Expand All @@ -77,8 +88,6 @@ echo "Collecting gentxs..."
echo "Validate genesis file"
./layerd genesis validate-genesis --home ~/.layer/alice



# Modify timeout_commit in config.toml for alice
echo "Modifying timeout_commit in config.toml for alice..."
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/' ~/.layer/alice/config/config.toml
Expand All @@ -89,7 +98,7 @@ sed -i 's/^laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g'
sed -i 's/^laddr = "tcp:\/\/127.0.0.1:26656"/laddr = "tcp:\/\/0.0.0.0:26656"/g' ~/.layer/alice/config/config.toml

sed -i 's/^address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:1317"/g' ~/.layer/alice/config/app.toml

sed -i 's/^address = "localhost:9090"/address = "0.0.0.0:9090"/g' ~/.layer/alice/config/app.toml


# Modify cors to accept *
Expand All @@ -106,11 +115,6 @@ sed -i 's/^enable-unsafe-cors = false/enable-unsafe-cors = true/g' ~/.layer/alic
sed -i 's/^enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' ~/.layer/config/app.toml
sed -i 's/^enable-unsafe-cors = false/enable-unsafe-cors = true/g' ~/.layer/config/app.toml

# set the external address for which to connect to
# echo "Setting external address to connect to for aws instance"
# sed -i 's/^external_address = ""/external_address = "18.215.40.125:26656"/g' ~/.layer/alice/config/config.toml
# sed -i 's/^external_address = ""/external_address = "18.215.40.125:26656"/g' ~/.layer/config/config.toml

# Modify keyring-backend in client.toml for alice
echo "Modifying keyring-backend in client.toml for alice..."
sed -i 's/^keyring-backend = "os"/keyring-backend = "test"/g' ~/.layer/alice/config/client.toml
Expand Down
4 changes: 4 additions & 0 deletions x/bridge/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ func (AppModule) ConsensusVersion() uint64 { return 1 }
// EndBlock contains the logic that is automatically triggered at the end of each block
func (am AppModule) EndBlock(ctx context.Context) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)
// todo: handle genesis state better?
if sdkCtx.BlockHeight() == 1 {
return nil
}
_, err := am.keeper.CompareBridgeValidators(sdkCtx)
if err != nil {
return err
Expand Down

0 comments on commit 2f58ade

Please sign in to comment.